Exemple #1
0
        public static MetaClassBuilder AddField(this MetaClassBuilder @this, string name, Action<MetaFieldBuilder> handler)
        {
            Check.This(@this);

            var builder = @this.AddField(name);

            if (handler != null)
                handler(builder);

            return @this;
        }
 public static SyncVersion AddField(this SyncVersion syncItem, IFieldInfo field, string value)
 {
     syncItem.AddField(field.FieldId, field.Name, field.Key, value, true);
     return syncItem;
 }
 public static void Field(
     this IObjectGraphType obj,
     string name,
     IGraphType type,
     string description = null,
     QueryArguments arguments = null,
     Func<ResolveFieldContext, object> resolve = null)
 {
     var field = new FieldType();
     field.Name = name;
     field.Description = description;
     field.Arguments = arguments;
     field.ResolvedType = type;
     field.Resolver = resolve != null ? new FuncFieldResolver<object>(resolve) : null;
     obj.AddField(field);
 }
	public static WWWForm Add(this WWWForm form, string key, string[] value)
	{
		form.AddField(key, value.ToStringArray());
		return form;
	}
	public static WWWForm Add(this WWWForm form, string key, Quaternion value)
	{
		form.AddField(key, value.ToString());
		return form;
	}
	public static WWWForm Add(this WWWForm form, string key, Color value)
	{
		form.AddField(key, value.ToHex());
		return form;
	}
	public static WWWForm Add(this WWWForm form, string key, string value)
	{
		form.AddField(key, value);
		return form;
	}
 /// <summary>
 /// Add default field with Index.NOT_ANALYZED
 /// </summary>
 /// <param name="document">Document to add Field</param>
 /// <param name="name">Field Name</param>
 /// <param name="value">Field Value</param>
 /// <param name="store">Field store type</param>
 /// <returns>The same Document with Field Added</returns>
 public static Document AddField(this Document document, string name, string value, Field.Store store)
 {
     return document.AddField(name, value, store, Field.Index.NOT_ANALYZED_NO_NORMS);
 }
        public static MethodDefinition CreateAddEventMethod(this TypeDefinition targetType, string eventName,
            TypeReference eventType, Assets assets, Action<ILProcessor> methodBodyWriter = null)
        {
            var method = new MethodDefinition("add_"+eventName,
                MethodAttributes.Final | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.NewSlot |
                MethodAttributes.Virtual | MethodAttributes.Public,
                assets.TypeReferences.Void)
            {
                Body = { InitLocals = true }
            };

            var eventHandlerParameter = new ParameterDefinition("value", ParameterAttributes.None, assets.TypeReferences.EventHandler);
            method.Parameters.Add(eventHandlerParameter);
            var il = method.Body.GetILProcessor();
            if (methodBodyWriter == null)
            {
                var varDef0 = new VariableDefinition(eventType);
                method.Body.Variables.Add(varDef0);
                var varDef1 = new VariableDefinition(eventType);
                method.Body.Variables.Add(varDef1);
                var varDef2 = new VariableDefinition(eventType);
                method.Body.Variables.Add(varDef2);
                var varDef3 = new VariableDefinition(assets.TypeReferences.Boolean);
                method.Body.Variables.Add(varDef3);
                var field = targetType.Fields.FirstOrDefault(fld => fld.Name == eventName);
                if (field == null)
                {
                    assets.Log.LogInfo(string.Format("Adding field {0} to {1} in CreateAddEventMethod.", 
                        eventName,
                        targetType.FullName));
                    field = targetType.AddField(eventType, eventName);
                }
                Instruction loopStart;
                il.Append(il.Create(OpCodes.Nop));
                il.Append(il.Create(OpCodes.Ldarg_0));
                il.Append(il.Create(OpCodes.Ldfld, field));
                il.Append(il.Create(OpCodes.Stloc_0));
                il.Append(loopStart = il.Create(OpCodes.Ldloc_0));
                il.Append(il.Create(OpCodes.Stloc_1));
                il.Append(il.Create(OpCodes.Ldloc_1));
                il.Append(il.Create(OpCodes.Ldarg_1));
                il.Append(il.Create(OpCodes.Call, assets.DelegateCombineMethodReference));
                il.Append(il.Create(OpCodes.Castclass, eventType));
                il.Append(il.Create(OpCodes.Stloc_2));
                il.Append(il.Create(OpCodes.Ldarg_0));
                il.Append(il.Create(OpCodes.Ldflda, field));
                il.Append(il.Create(OpCodes.Ldloc_2));
                il.Append(il.Create(OpCodes.Ldloc_1));
                il.Append(il.Create(OpCodes.Call, assets.InterlockedCompareExchangeOfEventHandler));
                il.Append(il.Create(OpCodes.Stloc_0));
                il.Append(il.Create(OpCodes.Ldloc_0));
                il.Append(il.Create(OpCodes.Ldloc_1));
                il.Append(il.Create(OpCodes.Ceq));
                il.Append(il.Create(OpCodes.Ldc_I4_0));
                il.Append(il.Create(OpCodes.Ceq));
                il.Append(il.Create(OpCodes.Stloc_3));
                il.Append(il.Create(OpCodes.Ldloc_3));
                il.Append(il.Create(OpCodes.Brtrue_S, loopStart));
                il.Append(il.Create(OpCodes.Ret));
            }
            else
            {
                methodBodyWriter(il);
            }
            return method;
        }
	public static WWWForm Add(this WWWForm form, string key, List<Color> value)
	{
		form.AddField(key, value.ToArray().ToStringArray());
		return form;
	}
Exemple #11
0
 public static void AddFieldLowerCase(this WWWForm form, string field, string value)
 {
     form.AddField(field, value.ToLower());
 }
Exemple #12
0
 public static void AddFieldIfValid(this WWWForm form, string field, string value, bool lowerCase=false)
 {
     if (string.IsNullOrEmpty(value) == false)
         form.AddField(field, lowerCase ? value.ToLower() : value);
 }
 /// <summary>
 /// Add field if contains string value. Add with Store.Yes and Field.Index.NOT_ANALYZED_NO_NORMS
 /// </summary>
 /// <param name="document"></param>
 /// <param name="name">Field Name</param>
 /// <param name="value">Field Value</param>
 /// <returns>The same Document with Field Added</returns>
 public static Document AddStringField(this Document document, string name, string value)
 {
     if (value != null && !string.Empty.Equals(value.Trim()))
         return document.AddField(name, value);
     return document;
 }
Exemple #14
0
 public static CodeMemberField AddField(this CodeTypeDeclaration typeDecl, Type type, string name)
 {
     return typeDecl.AddField(Easy.TypeRef(type), name);
 }
	public static WWWForm Add(this WWWForm form, string key, Vector4 value)
	{
		form.AddField(key, value.ToString());
		return form;
	}
 public static FieldStatement Field(this ClassStatement classStatement, string name)
 {
     var fieldStatement = new FieldStatement(name);
     classStatement.AddField(fieldStatement);
     return fieldStatement;
 }
 /// <summary>
 /// Add field to document with Store.Yes and Index.NOT_ANALYZED
 /// </summary>
 /// <param name="document">Document to add Field</param>
 /// <param name="name">Field Name</param>
 /// <param name="value">Field Value</param>
 /// <returns>The same Document with Field Added</returns>
 public static Document AddField(this Document document, string name, object value)
 {
     return document.AddField(name, value.ToEmptyString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
 }