Skip to content

Instantly share code, notes, and snippets.

@cjlotz
cjlotz / GenerateParameter.cs
Created October 25, 2018 08:10
Issue with content types
private async Task<SwaggerParameter> AddBodyParameterAsync(ResourceActionProcessorContext context, ResourceActionParameterDescriptor apiParameter)
{
var operation = context.OperationDescription.Operation;
JsonSchema4 schema = await GenerateSchema(context, apiParameter);
string contentType = context.ResourceAction.Action.Request.ContentType;
// NOTE CL: Workaround for bug in NSwag that overrides the custom content type - https://github.com/RSuter/NSwag/issues/1681
// By adding a Body parameter upfront instead of it being added implicitly when setting the operation.RequestBody, we
// prevent NSwag of overwriting our custom content type into application/json
public class ITTextInputLayout : TextInputLayout, IITComposite
{
public ITTextInputLayout(Context context) : this(context, null)
{
}
public ITTextInputLayout(Context context, IAttributeSet attrs) : this(context, attrs, Resource.Styleable.ITControls_ItcTextInputLayoutStyle)
{
}
@cjlotz
cjlotz / ITTextLayout_Full.cs
Created May 1, 2017 20:10
Full custom view
using Android.Content;
using Android.Util;
using Android.Support.Design.Widget;
using Android.Runtime;
using System;
using Android.Views;
using Android.Content.Res;
using Android.Text;
using Android.Views.InputMethods;
private bool _subscribed;
public EventHandler TextChanged;
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
Control.AfterTextChanged += HandleAfterTextChanged;
_subscribed = true;
@cjlotz
cjlotz / ITTextInputLayout_Properties.cs
Last active May 1, 2017 19:52
Control properties
public string Text
{
get { return Control.Text; }
set { Control.Text = value; }
}
public int MaxLines
{
get { return Control.MaxLines; }
set { Control.SetMaxLines(value); }
public interface IITComposite
{
string Error { get; set; }
string Header { get; set; }
string Text { get; set; }
}
@cjlotz
cjlotz / ITTextInputLayout_NewLayoutAlt.xml
Created May 1, 2017 19:40
New layout not using binding
<intouch.controls.ITTextInputLayout
android:id="@+id/layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
app:ItcHeader="Password"/>
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</merge>
<intouch.controls.ITTextInputLayout
android:id="@+id/layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
app:MvxLang="Header LabelPassword"
app:MvxBind="Text Password; Error Errors[Password] Converter=ErrorsToString"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:MvxLang="Hint LabelPassword">
<android.support.design.widget.TextInputEditText
android:id="@+id/control_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"