예제 #1
0
    protected override void Initialize()
    {
        base.Initialize();

        if (owner != null)
        {
            field = owner.GetType().GetField(name);
            if (field != null)
                value = field.GetValue(owner);
            else
            {
                prop = owner.GetType().GetProperty(name);
                if (prop != null)
                    value = prop.GetValue(owner, null);
            }

            if (value == null)
            {
                Debug.LogError("Orthello Action Tween variable [" + name + "] not found on " + (owner as OTObject).name + "!");
            }

        }
        else
        {
            Debug.LogError("Orthello Action Tween owner is null!");
        }


        if (getFromValue)
            fromValue = value;

    }
	static Pages_ReportLauncher()
	{
		_sendEmailMaint = System.Web.Compilation.BuildManager.GetType(_SENDEMAILMAINT_TYPE, false);
		_sendEmailMethod = null;
		MemberInfo[] search = null;
		if (_sendEmailMaint != null)
		{
			_sendEmailMethod = _sendEmailMaint.GetMethod(_SENDEMAIL_METHOD, BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public);
			search = _sendEmailMaint.GetMember(_SENDEMAILPARAMS_TYPE);
		}
		Type sendEmailParams = search != null && search.Length > 0 && search[0] is Type ? (Type)search[0] : null;
		if (sendEmailParams != null)
		{
			_sendEmailParamsCtor = sendEmailParams.GetConstructor(new Type[0]);
			_fromMethod = sendEmailParams.GetProperty("From");
			_toMethod = sendEmailParams.GetProperty("To");
			_ccMethod = sendEmailParams.GetProperty("Cc");
			_bccMethod = sendEmailParams.GetProperty("Bcc");
			_subjectMethod = sendEmailParams.GetProperty("Subject");
			_bodyMethod = sendEmailParams.GetProperty("Body");
			_activitySourceMethod = sendEmailParams.GetProperty("Source");
			_parentSourceMethod = sendEmailParams.GetProperty("ParentSource");
			_templateIDMethod = sendEmailParams.GetProperty("TemplateID");
			_attachmentsMethod = sendEmailParams.GetProperty("Attachments");
		}

		_canSendEmail = _sendEmailParamsCtor != null && _sendEmailMaint != null && _sendEmailMethod != null &&
			_fromMethod != null && _toMethod != null && _ccMethod != null && _bccMethod != null &&
			_subjectMethod != null && _bodyMethod != null &&
			_activitySourceMethod != null && _parentSourceMethod != null && _templateIDMethod != null && _attachmentsMethod != null && !PXSiteMap.IsPortal;

		Type reportFunctionsType = System.Web.Compilation.BuildManager.GetType(_REPORTFUNCTIONS_TYPE, false);
		if (reportFunctionsType != null)
			ExpressionContext.RegisterExternalObject("Payments", Activator.CreateInstance(reportFunctionsType));
	}
	// ctor. retrieves types, properties and methods
	static RelationsInspectorLink()
	{
		windowType = GetTypeInAssembly( riWindowTypeName, riAssemblyName );
		if ( windowType == null )
		{
			return; // this happens when RI is not installed. no need for an error msg here.
		}

		api1Property = windowType.GetProperty( api1PropertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty );
		if ( api1Property == null )
		{
			Debug.LogError( "Failed to retrieve API1 property of type " + windowType );
			return;
		}

		api1Type = GetTypeInAssembly( riAPI1TypeName, riAssemblyName );
		if ( api1Type == null )
		{
			Debug.LogError( "Failed to retrieve API1 type" );
			return;
		}

		api1ResetTargetsMethod = api1Type.GetMethod( api1ResetTargetsMethodName, api1ResetTargetsArguments );
		if ( api1ResetTargetsMethod == null )
		{
			Debug.LogError( "Failed to retrieve API method ResetTargets(object[],Type,bool)" );
			return;
		}

		RIisAvailable = true;
	}
예제 #4
0
 public void ShouldGenerateNameWithPropForList()
 {
     var info = new PropertyInfo(new ClassInfo { XmlName = "someClass" });
     info.XmlName = "someClass";
     info.IsList = true;
     Assert.That(info.GetCodeName(), Is.EqualTo("SomeClassProps"));
 }
예제 #5
0
 public void ShouldGenerateNameForListWithSAtTheEnd()
 {
     var info = new PropertyInfo(new ClassInfo { XmlName = "someClass" });
     info.XmlName = "tests";
     info.IsList = true;
     Assert.That(info.GetCodeName(), Is.EqualTo("Tests"));
 }
예제 #6
0
 void ProcessRes(PropertyInfo pi)
 {
     var obj = pi.GetValue(null, null);
     var type = obj.GetType();
     if(type == typeof(string))
     {
         var item = new RString();
         item.name = pi.Name;
         item.value = obj as string;
         listString.Add(item);
     }
     else if (type == typeof(Texture2D))
     {
         var item = new RTexture();
         item.name = pi.Name;
         item.value = obj as Texture2D;
         listTexture.Add(item);
     }
     else
     {
         var item = new RUnknown();
         item.name = pi.Name;
         item.type = type.Name;
         item.value = obj.ToString();
         listUnknown.Add(item);
     }
 }
예제 #7
0
        public Class Parse(String json, String className)
        {
            Class result = new Class(AccessModifier.Public, className);

            var oo = JsonConvert.DeserializeObject(json);
            var c = new ClassInfo(className);
            if (oo is JArray)
            {
                foreach (var jo in (JArray)oo)
                {
                    if (jo is JObject)
                    {
                        SetProperties(c, (JObject)jo);
                    }
                    else if (jo is JValue)
                    {
                        var pi = new PropertyInfo();
                        pi.Validate(jo);
                        return new Class(AccessModifier.Public, pi.GetCSharpTypeName());
                    }
                }
            }
            else if (oo is JObject)
            {
                SetProperties(c, (JObject)oo);
            }
            SetProperties(result, c);

            return result;
        }
예제 #8
0
        private static string ConvertToPropertyString(string entityName, PropertyInfo property)
        {
            string typeName = ConvertTypeName(property);

            var propertyString = string.Format(
            @"public static readonly Property<{0}> {1}Property = P<{2}>.Register(e => e.{1});
            ",
            typeName, property.Name, entityName);
            if (!string.IsNullOrEmpty(property.Comment))
            {
                propertyString += string.Format(
            @"/// <summary>
            /// {0}
            /// </summary>
            ", property.Comment);
            }
            propertyString += string.Format(
            @"public {0} {1}
            {{
            get {{ return this.GetProperty({1}Property); }}
            set {{ this.SetProperty({1}Property, value); }}
            }}", typeName, property.Name);

            return propertyString;
        }
예제 #9
0
        private static string ConvertTypeName(PropertyInfo property)
        {
            Type type = property.Type;
            if (type == typeof(decimal))
            {
                type = typeof(double);
            }

            string typeName = type.Name;
            if (type != typeof(string))
            {
                if (type == typeof(int))
                {
                    typeName = "int";
                }
                else if (type == typeof(double))
                {
                    typeName = "double";
                }
                else if (type == typeof(bool))
                {
                    typeName = "bool";
                }
                typeName += "?";
            }
            else
            {
                typeName = "string";
            }
            return typeName;
        }
예제 #10
0
 public PropertyAccessor(PropertyInfo propertyInfo)
     : base(propertyInfo)
 {
     _hasSetter = (propertyInfo.GetSetMethod(true) != null);
     if (_hasSetter)
         _lateBoundPropertySet = DelegateFactory.CreateSet(propertyInfo);
 }
예제 #11
0
		static API()
		{
			var editorAssembly = typeof(EditorWindow).Assembly;
			containerWindowType = editorAssembly.GetType("UnityEditor.ContainerWindow");
			viewType = editorAssembly.GetType("UnityEditor.View");
			dockAreaType = editorAssembly.GetType("UnityEditor.DockArea");
			parentField = typeof(EditorWindow).GetField("m_Parent", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic);
			if (dockAreaType != null)
			{
				panesField = dockAreaType.GetField("m_Panes", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic);
				addTabMethod = dockAreaType.GetMethod("AddTab", new System.Type[] { typeof(EditorWindow) });
			}
			if (containerWindowType != null)
			{
				windowsField = containerWindowType.GetProperty("windows", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic);
				mainViewField = containerWindowType.GetProperty("mainView", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (viewType != null)
				allChildrenField = viewType.GetProperty("allChildren", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic);
				
			FieldInfo windowsReorderedField = typeof(EditorApplication).GetField("windowsReordered", BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic);
			windowsReordered = windowsReorderedField.GetValue(null) as EditorApplication.CallbackFunction;

			System.Type projectWindowUtilType = editorAssembly.GetType("UnityEditor.ProjectWindowUtil");
			if (projectWindowUtilType != null)
				createAssetMethod = projectWindowUtilType.GetMethod("CreateAsset", new System.Type[] { typeof(Object), typeof(string) });
		}
예제 #12
0
	static Reports_RMLauncher()
	{
		_sendEmailMaint = System.Web.Compilation.BuildManager.GetType(_SENDEMAILMAINT_TYPE, false);
		_sendEmailMethod = null;
		MemberInfo[] search = null;
		if (_sendEmailMaint != null)
		{
			_sendEmailMethod = _sendEmailMaint.GetMethod(_SENDEMAIL_METHOD, BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public);
			search = _sendEmailMaint.GetMember(_SENDEMAILPARAMS_TYPE);
		}
		Type sendEmailParams = search != null && search.Length > 0 && search[0] is Type ? (Type)search[0] : null;
		if (sendEmailParams != null)
		{
			_sendEmailParamsCtor = sendEmailParams.GetConstructor(new Type[0]);
			_fromMethod = sendEmailParams.GetProperty("From");
			_toMethod = sendEmailParams.GetProperty("To");
			_ccMethod = sendEmailParams.GetProperty("Cc");
			_bccMethod = sendEmailParams.GetProperty("Bcc");
			_subjectMethod = sendEmailParams.GetProperty("Subject");
			_bodyMethod = sendEmailParams.GetProperty("Body");
			_activitySourceMethod = sendEmailParams.GetProperty("Source");
			_parentSourceMethod = sendEmailParams.GetProperty("ParentSource");
			_templateIDMethod = sendEmailParams.GetProperty("TemplateID");
			_attachmentsMethod = sendEmailParams.GetProperty("Attachments");
		}

		_canSendEmail = _sendEmailParamsCtor != null && _sendEmailMaint != null && _sendEmailMethod != null &&
			_fromMethod != null && _toMethod != null && _ccMethod != null && _bccMethod != null && 
			_subjectMethod != null && _bodyMethod != null &&
			_activitySourceMethod != null && _parentSourceMethod != null && _templateIDMethod != null && _attachmentsMethod != null;
	}
예제 #13
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Tween"/> class.
    /// </summary>
    /// <param name='targetObj'>
    /// The objet to perform the Tween on.
    /// </param>
    /// <param name='propertyName'>
    /// Property name, eg. "X", "Y", "ScaleX", "Alpha", etc.
    /// </param>
    /// <param name='endVal'>
    /// The value to tween to.  The tween will run from the property's value at start time to the end value.
    /// </param>
    /// <param name='duration'>
    /// Duration in seconds of the tween.
    /// </param>
    /// <param name='easingType'>
    /// Easing type.  Any function matching the see cref="EaseValue"/> delegate.  
    /// </param>
    /// <param name='delay'>
    /// Delay, in seconds.
    /// </param>
    /// <param name='startCallback'>
    /// Called when tween starts (after any delay).  
    /// </param>
    /// <param name='endCallback'>
    /// Called when tween ends
    /// </param>
    /// <exception cref='Exception'>
    /// Thrown when a Tween is created before Stage
    /// </exception>
    /// <exception cref='ArgumentException'>
    /// Thrown when targetObj param is null or targetObj does not have property referenced by propertyName arg.
    /// </exception>
    public Tween(DisplayObjectContainer targetObj, string propertyName, float endVal, float duration, EaseValue easingType, float delay = 0f, TweenCallback startCallback = null, TweenCallback endCallback = null)
    {
        if (TweenRunner.Instance == null)
            throw new Exception("TweenRunner must be added to Stage before creating Tweens");

        if (targetObj == null)
            throw new ArgumentException("targetObj is null");

        Id = Guid.NewGuid();
        TargetObj = targetObj;
        if (!String.IsNullOrEmpty(propertyName))
        {
            Property = targetObj.GetType().GetProperty(propertyName);
            if (Property == null)
                throw new ArgumentException("targetObj does not have property named " + propertyName);
        }
        //StartVal gets set when tween actually starts running, since the value may change during a delay
        EndVal = endVal;
        StartTime = TweenRunner.Instance.__GetCurrentTime();
        Duration = duration;
        EasingType = easingType;
        Delay = delay;
        StartCallback = startCallback;
        EndCallback = endCallback;

        if (!String.IsNullOrEmpty(propertyName))
            TweenRunner.Instance.__AddTween(this);
    }
예제 #14
0
    public static bool CanEdit(PropertyInfo property)
    {
        if (!property.CanRead)
        {
            return false;
        }

        var browsableAttribute = (BrowsableAttribute)Attribute.GetCustomAttribute(property, typeof(BrowsableAttribute), false);
        if (browsableAttribute != null && !browsableAttribute.Browsable)
        {
            return false;
        }

        var designerSerializationVisibilityAttribute = (DesignerSerializationVisibilityAttribute)Attribute.GetCustomAttribute(property, typeof(DesignerSerializationVisibilityAttribute), false);
        if (designerSerializationVisibilityAttribute != null && designerSerializationVisibilityAttribute.Visibility == DesignerSerializationVisibility.Hidden)
        {
            return false;
        }

        if (!property.CanWrite && !typeof(System.Collections.IList).IsAssignableFrom(property.PropertyType))
        {
            return false;
        }

        return true;
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalizedPropertyStringLengthRule"/> class.
        /// </summary>
        /// <param name="primaryProperty">
        /// The primary property.
        /// </param>
        /// <param name="mainProperty">
        /// The main property.
        /// </param>
        /// <param name="maxLength">
        /// The max length.
        /// </param>
        /// <param name="propertyDisplayName">
        /// The property display name.
        /// </param>
        /// <param name="resourceManager">
        /// The resource manager.
        /// </param>
        /// <param name="localizationName">
        /// The localization name.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="primaryProperty"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The <paramref name="maxLength"/> is less than zero.
        /// </exception>
        public LocalizedPropertyStringLengthRule(
            PropertyInfo<string> primaryProperty,
            PropertyInfo<string> mainProperty,
            int maxLength,
            string propertyDisplayName,
            ResourceManager resourceManager,
            string localizationName)
            : base(primaryProperty)
        {
            if (primaryProperty == null)
                throw new ArgumentNullException("primaryProperty");

            if (maxLength < 0)
                throw new ArgumentOutOfRangeException("maxLength");

            _primaryProperty = primaryProperty;
            _maxLength = maxLength;
            _propertyDisplayName = propertyDisplayName;
            _resourceManager = resourceManager;
            _mainProperty = mainProperty;
            _localizationName = localizationName;

            InputProperties = InputProperties ?? new List<IPropertyInfo>();
            InputProperties.Add(primaryProperty);

            if (_mainProperty != null)
                AffectedProperties.Add(_mainProperty);
        }
예제 #16
0
 public Watch(object obj, string field)
 {
     this.obj = obj;
     this.fieldName = field;
     Type type = this.obj.GetType();
     this.field = type.GetField(field, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
     this.property = type.GetProperty(field, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
 }
예제 #17
0
 public void boolField(object pObject, PropertyInfo pPropertyInfo)
 {
     bool lValue = (bool)pPropertyInfo.GetValue(pObject, null);
     content.text="";
     bool lNewValue = GUILayout.Toggle(lValue, content);
     if(lValue!=lNewValue)
         pPropertyInfo.SetValue(pObject, lNewValue, null);
 }
예제 #18
0
 public PropertyOperation(PropertyInfo propertyInfo)
 {
     if (propertyInfo == null)
     {
         throw new ArgumentNullException("pi");
     }
     this.propertyInfo = propertyInfo;
 }
예제 #19
0
 public ValueTypePropertyAccessor(PropertyInfo propertyInfo)
     : base(propertyInfo)
 {
     var setMethod = propertyInfo.GetSetMethod(true);
     _hasSetter = (setMethod != null);
     if (_hasSetter)
         _lateBoundPropertySet = setMethod;
 }
예제 #20
0
 public PropertyDecorator(TypeModel model, Type forType, PropertyInfo property, IProtoSerializer tail) : base(tail)
 {
     Helpers.DebugAssert(forType != null);
     Helpers.DebugAssert(property != null);
     this.forType = forType;
     this.property = property;
     SanityCheck(model, property, tail, out readOptionsWriteValue, true, true);
     shadowSetter = GetShadowSetter(model, property);
 }
예제 #21
0
 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Incorrect parameter to from-nearest-specified-value function");
     }
     return pInfo.getPropertyList().GetNearestSpecifiedProperty(propName);
 }
예제 #22
0
 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Incorrect parameter to from-table-column function");
     }
     throw new PropertyException("from-table-column unimplemented!");
 }
예제 #23
0
 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Incorrect parameter to inherited-property-value function");
     }
     return pInfo.getPropertyList().GetInheritedProperty(propName);
 }
예제 #24
0
 public override Property Eval(Property[] args, PropertyInfo propInfo)
 {
     Numeric num = args[0].GetNumeric();
     if (num == null)
     {
         throw new PropertyException("Non numeric operand to abs function");
     }
     return new NumericProperty(num.abs());
 }
예제 #25
0
 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Missing property name.");
     }
     return pInfo.getPropertyList().GetProperty(propName);
 }
예제 #26
0
 static Solution()
 {
     s_SolutionParser = Type.GetType("Microsoft.Build.Construction.SolutionParser, Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", false, false);
     if (s_SolutionParser != null)
     {
         s_SolutionParser_solutionReader = s_SolutionParser.GetProperty("SolutionReader", BindingFlags.NonPublic | BindingFlags.Instance);
         s_SolutionParser_projects = s_SolutionParser.GetProperty("Projects", BindingFlags.NonPublic | BindingFlags.Instance);
         s_SolutionParser_parseSolution = s_SolutionParser.GetMethod("ParseSolution", BindingFlags.NonPublic | BindingFlags.Instance);
     }
 }
예제 #27
0
 public ChangerFloat Create(string t_propertyName, GameObjectEx t_invoker, float t_time, float t_startVal, float t_endVal)
 {
     m_property = t_invoker.GetType().GetProperty(t_propertyName);
     m_time = t_time;
     m_startVal = t_startVal;
     m_endVal = t_endVal;
     m_activated = true;
     m_invoker = t_invoker;
     return this;
 }
예제 #28
0
        public override Property Eval(Property[] args, PropertyInfo pInfo)
        {
            string propName = args[0].GetString();
            if (propName == null)
            {
                throw new PropertyException("Incorrect parameter to from-parent function");
            }

            return pInfo.getPropertyList().GetFromParentProperty(propName);
        }
예제 #29
0
 public override void OnEntry(MethodExecutionEventArgs eventArgs)
 {
   //save old value in order to check if setter actually changes value, only fire OnSetter if it does change
   if (prop == null) prop = eventArgs.Instance.GetType().GetProperty(eventArgs.Method.Name.Replace("set_", ""));
   if (prop != null)
   {
     object oldobj = prop.GetValue(eventArgs.Instance, null);
     if (oldobj != null) oldVal = oldobj.ToString();
   }
 }
예제 #30
0
 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     Numeric n1 = args[0].GetNumeric();
     Numeric n2 = args[1].GetNumeric();
     if (n1 == null || n2 == null)
     {
         throw new PropertyException("Non numeric operands to max function");
     }
     return new NumericProperty(n1.max(n2));
 }
예제 #31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbMetadata"/> class.
        /// </summary>
        /// <param name="productName">Name of the product.</param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="connectionType">Type of the connection.</param>
        /// <param name="commandType">Type of the command.</param>
        /// <param name="parameterType">Type of the parameter.</param>
        /// <param name="dataAdapterType">Type of the data adapter.</param>
        /// <param name="commandBuilderType">Type of the command builder.</param>
        /// <param name="commandBuilderDeriveParametersMethod">The command builder derive parameters method.</param>
        /// <param name="parameterDbType">Type of the parameter db.</param>
        /// <param name="parameterDbTypeProperty">The parameter db type property.</param>
        /// <param name="parameterIsNullableProperty">The parameter is nullable property.</param>
        /// <param name="parameterNamePrefix">The parameter name prefix.</param>
        /// <param name="exceptionType">Type of the exception.</param>
        /// <param name="useParameterNamePrefixInParameterCollection">if set to <c>true</c> [use parameter name prefix in parameter collection].</param>
        /// <param name="useParameterPrefixInSql">if set to <c>true</c> [use parameter prefix in SQL].</param>
        /// <param name="bindByName">if set to <c>true</c> [bind by name].</param>
        /// <param name="errorCodeExceptionExpression">The error code exception expression.</param>
        public DbMetadata(string productName,
                          string assemblyName,
                          Type connectionType,
                          Type commandType,
                          Type parameterType,
                          Type dataAdapterType,
                          Type commandBuilderType,
                          string commandBuilderDeriveParametersMethod,
                          Type parameterDbType,
                          string parameterDbTypeProperty,
                          string parameterIsNullableProperty,
                          string parameterNamePrefix,
                          Type exceptionType,
                          bool useParameterNamePrefixInParameterCollection,
                          bool useParameterPrefixInSql,
                          bool bindByName,
                          string errorCodeExceptionExpression

                          )
        {
            AssertUtils.ArgumentHasText(productName, "ProductName");
            this.productName = productName;
            AssertUtils.ArgumentHasText(assemblyName, "assemblyName", GetErrorMessage());
            AssertUtils.ArgumentNotNull(connectionType, "connectionType", GetErrorMessage());
            AssertUtils.ArgumentNotNull(commandType, "commandType", GetErrorMessage());
            AssertUtils.ArgumentNotNull(parameterType, "parameterType", GetErrorMessage());
            AssertUtils.ArgumentNotNull(dataAdapterType, "dataAdapterType", GetErrorMessage());
            AssertUtils.ArgumentNotNull(commandBuilderType, "commandBuilderType", GetErrorMessage());
            AssertUtils.ArgumentHasText(commandBuilderDeriveParametersMethod, "commandBuilderDeriveParametersMethod", GetErrorMessage());
            AssertUtils.ArgumentNotNull(parameterDbType, "parameterDbType", GetErrorMessage());
            AssertUtils.ArgumentHasText(parameterDbTypeProperty, "parameterDbTypeProperty", GetErrorMessage());
            AssertUtils.ArgumentHasText(parameterIsNullableProperty, "parameterIsNullableProperty", GetErrorMessage());
            AssertUtils.ArgumentHasText(parameterNamePrefix, "parameterNamePrefix", GetErrorMessage());
            AssertUtils.ArgumentNotNull(exceptionType, "exceptionType", GetErrorMessage());

            this.assemblyName = assemblyName;

            this.connectionType     = connectionType;
            this.commandType        = commandType;
            this.parameterType      = parameterType;
            this.dataAdapterType    = dataAdapterType;
            this.commandBuilderType = commandBuilderType;

            if (commandBuilderDeriveParametersMethod.ToLower().Trim().Equals("not supported"))
            {
                supportsDeriveParametersMethod = false;
            }

            if (supportsDeriveParametersMethod)
            {
                this.commandBuilderDeriveParametersMethod =
                    ReflectionUtils.GetMethod(this.commandBuilderType, commandBuilderDeriveParametersMethod,
                                              new Type[] { this.commandType });

                AssertUtils.ArgumentNotNull(this.commandBuilderDeriveParametersMethod,
                                            "commandBuilderDeriveParametersMethod", GetErrorMessage() +
                                            ", could not resolve commandBuilderDeriveParametersMethod " +
                                            commandBuilderDeriveParametersMethod +
                                            " to MethodInfo.  Please check dbproviders.xml entry for correct metadata listing.");
            }

            this.commandType = commandType;

            this.parameterDbType = parameterDbType;

            this.parameterDbTypeProperty = this.parameterType.GetProperty(parameterDbTypeProperty,
                                                                          BindingFlags.Instance | BindingFlags.Public);
            AssertUtils.ArgumentNotNull(this.parameterDbTypeProperty, "parameterDbTypeProperty", GetErrorMessage() +
                                        ", could not resolve parameterDbTypeProperty " +
                                        parameterDbTypeProperty +
                                        " to PropertyInfo.  Please check dbproviders.xml entry for correct metadata listing.");

            this.parameterIsNullableProperty = this.parameterType.GetProperty(parameterIsNullableProperty,
                                                                              BindingFlags.Instance | BindingFlags.Public);

            AssertUtils.ArgumentNotNull(this.parameterIsNullableProperty, "parameterIsNullableProperty", GetErrorMessage() +
                                        ", could not resolve parameterIsNullableProperty " +
                                        parameterIsNullableProperty +
                                        " to PropertyInfo.  Please check dbproviders.xml entry for correct metadata listing.");

            this.parameterNamePrefix = parameterNamePrefix;
            this.exceptionType       = exceptionType;

            this.useParameterNamePrefixInParameterCollection = useParameterNamePrefixInParameterCollection;
            this.useParameterPrefixInSql = useParameterPrefixInSql;
            this.bindByName = bindByName;

            this.errorCodeExceptionExpression = errorCodeExceptionExpression;


            errorCodes = new ErrorCodes();
        }
예제 #32
0
        private static void AppendAttrubiteNode(XmlDocument doc, ConfigElementAttribute att, PropertyInfo property)
        {
            XmlNode      xmlNode      = doc.CreateElement("att");
            XmlAttribute xmlAttribute = doc.CreateAttribute("Property");

            xmlAttribute.Value = property.Name;
            xmlNode.Attributes.Append(xmlAttribute);
            XmlAttribute xmlAttribute2 = doc.CreateAttribute("Name");

            xmlAttribute2.Value = (string.IsNullOrEmpty(att.Name) ? property.Name : att.Name);
            xmlNode.Attributes.Append(xmlAttribute2);
            XmlAttribute xmlAttribute3 = doc.CreateAttribute("Description");

            xmlAttribute3.Value = att.Description;
            xmlNode.Attributes.Append(xmlAttribute3);
            XmlAttribute xmlAttribute4 = doc.CreateAttribute("Nullable");

            xmlAttribute4.Value = att.Nullable.ToString();
            xmlNode.Attributes.Append(xmlAttribute4);
            XmlAttribute xmlAttribute5 = doc.CreateAttribute("InputType");

            xmlAttribute5.Value = ((int)att.InputType).ToString();
            xmlNode.Attributes.Append(xmlAttribute5);
            if (att.Options != null && att.Options.Length > 0)
            {
                XmlNode  xmlNode2 = doc.CreateElement("Options");
                string[] options  = att.Options;
                for (int i = 0; i < options.Length; i++)
                {
                    string  innerText = options[i];
                    XmlNode xmlNode3  = doc.CreateElement("Item");
                    xmlNode3.InnerText = innerText;
                    xmlNode2.AppendChild(xmlNode3);
                }
                xmlNode.AppendChild(xmlNode2);
            }
            doc.SelectSingleNode("xml").AppendChild(xmlNode);
        }
예제 #33
0
        protected override bool IsFieldTypeSupported(PropertyInfo field)
        {
            IDictionary <string, string> s;

            return(!field.PropertyType.IsImplementing <IEnumerable>());
        }
예제 #34
0
        private static void WriteValue(object obj, JsonWriter writer,
                                       bool writer_is_private,
                                       int depth)
        {
            if (depth > max_nesting_depth)
            {
                throw new JsonException(
                          String.Format("Max allowed object depth reached while " +
                                        "trying to export from type {0}",
                                        obj.GetType()));
            }

            if (obj == null)
            {
                writer.Write(null);
                return;
            }

            if (obj is IJsonWrapper)
            {
                if (writer_is_private)
                {
                    writer.TextWriter.Write(((IJsonWrapper)obj).ToJson());
                }
                else
                {
                    ((IJsonWrapper)obj).ToJson(writer);
                }

                return;
            }

            if (obj is String)
            {
                writer.Write((string)obj);
                return;
            }

            if (obj is Double)
            {
                writer.Write((double)obj);
                return;
            }

            if (obj is Int32)
            {
                writer.Write((int)obj);
                return;
            }

            if (obj is Boolean)
            {
                writer.Write((bool)obj);
                return;
            }

            if (obj is Int64)
            {
                writer.Write((long)obj);
                return;
            }

            if (obj is Array)
            {
                writer.WriteArrayStart();

                foreach (object elem in (Array)obj)
                {
                    WriteValue(elem, writer, writer_is_private, depth + 1);
                }

                writer.WriteArrayEnd();

                return;
            }

            if (obj is IList)
            {
                writer.WriteArrayStart();
                foreach (object elem in (IList)obj)
                {
                    WriteValue(elem, writer, writer_is_private, depth + 1);
                }
                writer.WriteArrayEnd();

                return;
            }

            if (obj is IDictionary)
            {
                writer.WriteObjectStart();
                foreach (DictionaryEntry entry in (IDictionary)obj)
                {
                    Console.WriteLine(entry + "===" + entry.Key);
                    writer.WritePropertyName((string)entry.Key);
                    WriteValue(entry.Value, writer, writer_is_private,
                               depth + 1);
                }
                writer.WriteObjectEnd();

                return;
            }

            Type obj_type = obj.GetType();

            // See if there's a custom exporter for the object
            if (custom_exporters_table.ContainsKey(obj_type))
            {
                ExporterFunc exporter = custom_exporters_table[obj_type];
                exporter(obj, writer);

                return;
            }

            // If not, maybe there's a base exporter
            if (base_exporters_table.ContainsKey(obj_type))
            {
                ExporterFunc exporter = base_exporters_table[obj_type];
                exporter(obj, writer);

                return;
            }

            // Last option, let's see if it's an enum
            if (obj is Enum)
            {
                Type e_type = Enum.GetUnderlyingType(obj_type);

                if (e_type == typeof(long) ||
                    e_type == typeof(uint) ||
                    e_type == typeof(ulong))
                {
                    writer.Write((ulong)obj);
                }
                else
                {
                    writer.Write((int)obj);
                }

                return;
            }

            // Okay, so it looks like the input should be exported as an
            // object
            AddTypeProperties(obj_type);
            IList <PropertyMetadata> props = type_properties[obj_type];

            writer.WriteObjectStart();
            foreach (PropertyMetadata p_data in props)
            {
                if (p_data.IsField)
                {
                    writer.WritePropertyName(p_data.Info.Name);
                    WriteValue(((FieldInfo)p_data.Info).GetValue(obj),
                               writer, writer_is_private, depth + 1);
                }
                else
                {
                    PropertyInfo p_info = (PropertyInfo)p_data.Info;

                    if (p_info.CanRead)
                    {
                        writer.WritePropertyName(p_data.Info.Name);
                        WriteValue(p_info.GetValue(obj, null),
                                   writer, writer_is_private, depth + 1);
                    }
                }
            }
            writer.WriteObjectEnd();
        }
예제 #35
0
 protected override object ResolveCommandTarget(ICommandMessage msg, object parent, PropertyInfo field, IEntityModel childEntityModel)
 {
     return(field.GetValue(parent));
 }
 /// <summary>
 ///     Creates the locator.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <returns>The value.</returns>
 public override IElementLocator CreateLocator(PropertyInfo propertyInfo)
 {
     return(new AjaxElementLocator(searchContext, new HtmlElementPropertyAttributesHandler(propertyInfo)));
 }
예제 #37
0
        public JsonSonuc yeniProjeMusterisi(HttpRequestBase Request, string[] musteriList)
        {
            try
            {
                vrlfgysdbEntities db = new vrlfgysdbEntities();

                foreach (string str in musteriList)
                {
                    int vid = 1;
                    if (db.proje_musteri.Count() != 0)
                    {
                        vid = db.proje_musteri.Max(e => e.vid) + 1;
                    }
                    int sort = 1;
                    if (db.proje_musteri.Count() != 0)
                    {
                        sort = db.proje_musteri.Max(e => e.sort) + 1;
                    }

                    proje_musteri pm = new proje_musteri();
                    foreach (var property in pm.GetType().GetProperties())
                    {
                        try
                        {
                            var response = Request[property.Name];
                            if (response == null && property.PropertyType != typeof(int))
                            {
                                if (response == null)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                PropertyInfo propertyS = pm.GetType().GetProperty(property.Name);
                                if (property.PropertyType == typeof(decimal))
                                {
                                    propertyS.SetValue(pm, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                                }
                                else if (property.PropertyType == typeof(int))
                                {
                                    if (response == null)
                                    {
                                        propertyS.SetValue(pm, Convert.ChangeType(0, property.PropertyType), null);
                                    }
                                    else
                                    {
                                        propertyS.SetValue(pm, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                                    }
                                }
                                else
                                {
                                    propertyS.SetValue(pm, Convert.ChangeType(response, property.PropertyType), null);
                                }
                            }
                        }
                        catch (Exception)
                        { }
                    }

                    pm.flag       = durumlar.aktif;
                    pm.date       = DateTime.Now;
                    pm.vid        = vid;
                    pm.sort       = sort;
                    pm.ekleyen    = GetCurrentUser.GetUser().id;
                    pm.musteri_id = Convert.ToInt32(str);

                    proje_musteri dbPm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == pm.proje_id && e.musteri_id == pm.musteri_id).FirstOrDefault();
                    if (dbPm != null)
                    {
                        continue;
                        //return JsonSonuc.sonucUret(true, "Müşteri Eklendi.");
                    }

                    db.proje_musteri.Add(pm);
                    db.SaveChanges();
                }

                return(JsonSonuc.sonucUret(true, "Müşteri Eklendi."));
            }
            catch (Exception e)
            {
                return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz."));
            }
        }
예제 #38
0
 public virtual void OnNavigationRemoved(
     [NotNull] InternalEntityTypeBuilder sourceEntityTypeBuilder,
     [NotNull] InternalEntityTypeBuilder targetEntityTypeBuilder,
     [NotNull] string navigationName,
     [CanBeNull] PropertyInfo propertyInfo)
 => Add(new OnNavigationRemovedNode(sourceEntityTypeBuilder, targetEntityTypeBuilder, navigationName, propertyInfo));
예제 #39
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 protected virtual InternalRelationshipBuilder WithOneBuilder([CanBeNull] PropertyInfo navigationProperty)
 => WithOneBuilder(PropertyIdentity.Create(navigationProperty));
예제 #40
0
        /// <summary>
        /// 获取数据库的字段名
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TKey"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static string GetFieldName <T, TKey>(this Expression <Func <T, TKey> > expression) where T : class, new()
        {
            PropertyInfo property = expression.ToPropertyInfo();

            return(property.GetAttribute <ColumnAttribute>()?.Name ?? property.Name);
        }
예제 #41
0
        private static TargetDefinition LoadTargetDefinition(NukeBuild build, PropertyInfo property)
        {
            var targetFactory = (Target)property.GetValue(build);

            return(TargetDefinition.Create(property.Name, targetFactory));
        }
예제 #42
0
            /// <summary>
            /// Uses Lamda expressions to create a Func<T,object> that invokes the given property getter.
            /// The property value will be extracted and cast to type TProperty
            /// </summary>
            /// <typeparam name="TObject">The type of the object declaring the property.</typeparam>
            /// <typeparam name="TProperty">The type to cast the property value to</typeparam>
            /// <param name="pi">PropertyInfo pointing to the property to wrap</param>
            /// <returns></returns>
            static Func <TObject, TProperty> MakePropertyAccessor <TObject, TProperty>(PropertyInfo pi)
            {
                ParameterExpression objParam      = Expression.Parameter(typeof(TObject), "obj");
                MemberExpression    typedAccessor = Expression.PropertyOrField(objParam, pi.Name);
                UnaryExpression     castToObject  = Expression.Convert(typedAccessor, typeof(object));
                LambdaExpression    lambdaExpr    = Expression.Lambda <Func <TObject, TProperty> >(castToObject, objParam);

                return((Func <TObject, TProperty>)lambdaExpr.Compile());
            }
예제 #43
0
 public MatchingResult Match(PropertyInfo expectedProperty, JToken actualValue)
 {
     return(TypeMatchingResultHelper.CreateMatchingResult(JTokenType.TimeSpan, actualValue));
 }
예제 #44
0
 /// <summary>
 /// Gets the total size of this field when it's encoded.
 /// </summary>
 /// <returns>An integer that represents the number of bytes that will be used once it is encoded.</returns>
 public virtual int DataSize(Record record, PropertyInfo property)
 {
     return(Size);
 }
        /// <summary>
        /// Get the Elastic Search Field Type Related.
        /// </summary>
        /// <param name="att">ElasticPropertyAttribute</param>
        /// <param name="p">Property Field</param>
        /// <returns>String with the type name or null if can not be inferres</returns>
        private static string GetElasticSearchType(ElasticsearchPropertyAttribute att, PropertyInfo p)
        {
            FieldType?fieldType = att.Type;

            if (fieldType == FieldType.None)
            {
                fieldType = GetFieldTypeFromType(p.PropertyType);
            }

            return(GetElasticSearchTypeFromFieldType(fieldType));
        }
예제 #46
0
 /// <summary>
 /// Encode a field by writing the property value into the writer.
 /// </summary>
 /// <param name="writer">The writer that will contain the encoded data.</param>
 /// <param name="record">The object whose property will be encoded.</param>
 /// <param name="property">The information abou the property to be encoded.</param>
 public abstract void EncodeField(BinaryWriter writer, Record record, PropertyInfo property);
예제 #47
0
        public string projeDuzenle(string url, int firma_id, HttpRequestBase Request)
        {
            try
            {
                vrlfgysdbEntities db = new vrlfgysdbEntities();

                proje_surec dbPrj = db.proje_surec.Where(e => e.url.Equals(url) && e.flag != durumlar.silindi).FirstOrDefault();

                if (dbPrj == null || url == null || url.Equals(""))
                {
                    return(yeniProje(firma_id, Request));
                }
                else if (!(dbPrj.flag != durumlar.silindi))
                {
                    return("");
                }

                string urlTemp = dbPrj.url;

                foreach (var property in dbPrj.GetType().GetProperties())
                {
                    try
                    {
                        var response = Request[property.Name];
                        if (response == null)
                        {
                            if (response == null)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            PropertyInfo propertyS = dbPrj.GetType().GetProperty(property.Name);
                            if (property.PropertyType == typeof(decimal))
                            {
                                propertyS.SetValue(dbPrj, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                            }
                            else
                            {
                                propertyS.SetValue(dbPrj, Convert.ChangeType(response, property.PropertyType), null);
                            }
                        }
                    }
                    catch (Exception)
                    { }
                }

                dbPrj.url = urlTemp;

                string          isimControl   = "select * from proje_surec where id != " + dbPrj.id.ToString() + " and tur = " + ProjeSurecTur.proje + " and flag != " + durumlar.silindi.ToString() + " and isim = '" + dbPrj.isim + "' and firma_id = " + dbPrj.firma_id;
                ProjeSurecModel isimKontrolPs = db.Database.SqlQuery <ProjeSurecModel>(isimControl).FirstOrDefault();
                if (isimKontrolPs != null)
                {
                    return("proje_isim_hatasi");
                }

                bool kullaniciKontrol = firmaProjeKontrol(dbPrj.firma_id, dbPrj.id).Result;
                if (!kullaniciKontrol)
                {
                    return("proje_sayisi_hatasi");
                }

                db.Entry(dbPrj).State = EntityState.Modified;
                db.SaveChanges();

                /*#region proje_musteri
                 * int musteri_id = Convert.ToInt32(Request["musteri_id"].ToString());
                 * if (musteri_id != 0)
                 * {
                 *  proje_surec dbPs = db.proje_surec.Where(e => e.vid == dbPrj.vid).FirstOrDefault();
                 *  proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault();
                 *  if (pm == null)
                 *  {
                 *      pm = new proje_musteri();
                 *      pm.date = DateTime.Now;
                 *      pm.flag = durumlar.aktif;
                 *      pm.musteri_id = musteri_id;
                 *      pm.proje_id = dbPs.id;
                 *      int vidPm = 1;
                 *      if (db.proje_musteri.Count() != 0)
                 *      {
                 *          vidPm = db.proje_musteri.Max(e => e.vid) + 1;
                 *      }
                 *      int sortPm = 1;
                 *      if (db.proje_musteri.Count() != 0)
                 *      {
                 *          sortPm = db.proje_musteri.Max(e => e.sort) + 1;
                 *      }
                 *      pm.sort = sortPm;
                 *      pm.vid = vidPm;
                 *      db.proje_musteri.Add(pm);
                 *      db.SaveChanges();
                 *  }
                 *  else if (pm != null && pm.musteri_id != musteri_id)
                 *  {
                 *      pm.musteri_id = musteri_id;
                 *      db.Entry(pm).State = EntityState.Modified;
                 *      db.SaveChanges();
                 *  }
                 * }
                 * else if (musteri_id == 0)
                 * {
                 *  proje_surec dbPs = db.proje_surec.Where(e => e.vid == dbPrj.vid).FirstOrDefault();
                 *  proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault();
                 *  if (pm != null)
                 *  {
                 *      pm.flag = durumlar.silindi;
                 *      db.Entry(pm).State = EntityState.Modified;
                 *      db.SaveChanges();
                 *  }
                 * }
                 #endregion proje_musteri*/

                return(dbPrj.url);
            }
            catch (Exception e)
            {
                return("");
            }
        }
예제 #48
0
 protected override IEntityModel ExtractChildEntityModel(IEntityModel declaringEntity, IDictionary <string, object> attributes, PropertyInfo field)
 {
     return(declaringEntity.ModelOf(field.PropertyType));
 }
예제 #49
0
        public async Task Generate_EndToEnd()
        {
            // construct our TimerTrigger attribute ([TimerTrigger("00:00:02", RunOnStartup = true)])
            Collection <ParameterDescriptor> parameters = new Collection <ParameterDescriptor>();
            ParameterDescriptor    parameter            = new ParameterDescriptor("timerInfo", typeof(TimerInfo));
            ConstructorInfo        ctorInfo             = typeof(TimerTriggerAttribute).GetConstructor(new Type[] { typeof(string) });
            PropertyInfo           runOnStartupProperty = typeof(TimerTriggerAttribute).GetProperty("RunOnStartup");
            CustomAttributeBuilder attributeBuilder     = new CustomAttributeBuilder(
                ctorInfo,
                new object[] { "00:00:02" },
                new PropertyInfo[] { runOnStartupProperty },
                new object[] { true });

            parameter.CustomAttributes.Add(attributeBuilder);
            parameters.Add(parameter);

            // create the FunctionDefinition
            FunctionMetadata   metadata = new FunctionMetadata();
            TestInvoker        invoker  = new TestInvoker();
            FunctionDescriptor function = new FunctionDescriptor("TimerFunction", invoker, metadata, parameters);
            Collection <FunctionDescriptor> functions = new Collection <FunctionDescriptor>();

            functions.Add(function);

            // Get the Type Attributes (in this case, a TimeoutAttribute)
            ScriptHostConfiguration scriptConfig = new ScriptHostConfiguration();

            scriptConfig.FunctionTimeout = TimeSpan.FromMinutes(5);
            Collection <CustomAttributeBuilder> typeAttributes = ScriptHost.CreateTypeAttributes(scriptConfig);

            // generate the Type
            Type functionType = FunctionGenerator.Generate("TestScriptHost", "TestFunctions", typeAttributes, functions);

            // verify the generated function
            MethodInfo       method           = functionType.GetMethod("TimerFunction");
            TimeoutAttribute timeoutAttribute = (TimeoutAttribute)functionType.GetCustomAttributes().Single();

            Assert.Equal(TimeSpan.FromMinutes(5), timeoutAttribute.Timeout);
            Assert.True(timeoutAttribute.ThrowOnTimeout);
            Assert.True(timeoutAttribute.TimeoutWhileDebugging);
            ParameterInfo         triggerParameter = method.GetParameters()[0];
            TimerTriggerAttribute triggerAttribute = triggerParameter.GetCustomAttribute <TimerTriggerAttribute>();

            Assert.NotNull(triggerAttribute);

            // start the JobHost which will start running the timer function
            JobHostConfiguration config = new JobHostConfiguration()
            {
                TypeLocator = new TypeLocator(functionType)
            };

            config.UseTimers();
            JobHost host = new JobHost(config);

            await host.StartAsync();

            await Task.Delay(3000);

            await host.StopAsync();

            // verify our custom invoker was called
            Assert.True(invoker.InvokeCount >= 2);
        }
예제 #50
0
        private static object ReadValue(Type inst_type, JsonReader reader)
        {
            reader.Read();

            if (reader.Token == JsonToken.ArrayEnd)
            {
                return(null);
            }

            Type underlying_type = Nullable.GetUnderlyingType(inst_type);
            Type value_type      = underlying_type ?? inst_type;

            if (reader.Token == JsonToken.Null)
            {
                if (inst_type.IsClass || underlying_type != null)
                {
                    return(null);
                }

                throw new JsonException(String.Format(
                                            "Can't assign null to an instance of type {0}",
                                            inst_type));
            }

            if (reader.Token == JsonToken.Double ||
                reader.Token == JsonToken.Int ||
                reader.Token == JsonToken.Long ||
                reader.Token == JsonToken.String ||
                reader.Token == JsonToken.Boolean)
            {
                Type json_type = reader.Value.GetType();

                if (value_type.IsAssignableFrom(json_type))
                {
                    return(reader.Value);
                }

                // If there's a custom importer that fits, use it
                if (custom_importers_table.ContainsKey(json_type) &&
                    custom_importers_table[json_type].ContainsKey(
                        value_type))
                {
                    ImporterFunc importer =
                        custom_importers_table[json_type][value_type];

                    return(importer(reader.Value));
                }

                // Maybe there's a base importer that works
                if (base_importers_table.ContainsKey(json_type) &&
                    base_importers_table[json_type].ContainsKey(
                        value_type))
                {
                    ImporterFunc importer =
                        base_importers_table[json_type][value_type];

                    return(importer(reader.Value));
                }

                // Maybe it's an enum
                if (value_type.IsEnum)
                {
                    return(Enum.ToObject(value_type, reader.Value));
                }

                // Try using an implicit conversion operator
                MethodInfo conv_op = GetConvOp(value_type, json_type);

                if (conv_op != null)
                {
                    return(conv_op.Invoke(null,
                                          new object[] { reader.Value }));
                }

                // No luck
                //throw new JsonException (String.Format (
                //        "Can't assign value '{0}' (type {1}) to type {2}",
                //        reader.Value, json_type, inst_type));
            }

            object instance = null;

            if (reader.Token == JsonToken.ArrayStart)
            {
                AddArrayMetadata(inst_type);
                ArrayMetadata t_data = array_metadata[inst_type];

                if (!t_data.IsArray && !t_data.IsList)
                {
                    throw new JsonException(String.Format(
                                                "Type {0} can't act as an array",
                                                inst_type));
                }

                IList list;
                Type  elem_type;

                if (!t_data.IsArray)
                {
                    list      = (IList)Activator.CreateInstance(inst_type);
                    elem_type = t_data.ElementType;
                }
                else
                {
                    list      = new ArrayList();
                    elem_type = inst_type.GetElementType();
                }

                while (true)
                {
                    object item = ReadValue(elem_type, reader);
                    if (item == null && reader.Token == JsonToken.ArrayEnd)
                    {
                        break;
                    }

                    list.Add(item);
                }

                if (t_data.IsArray)
                {
                    int n = list.Count;
                    instance = Array.CreateInstance(elem_type, n);

                    for (int i = 0; i < n; i++)
                    {
                        ((Array)instance).SetValue(list[i], i);
                    }
                }
                else
                {
                    instance = list;
                }
            }
            else if (reader.Token == JsonToken.ObjectStart)
            {
                AddObjectMetadata(value_type);
                ObjectMetadata t_data = object_metadata[value_type];

                instance = Activator.CreateInstance(value_type);

                while (true)
                {
                    reader.Read();

                    if (reader.Token == JsonToken.ObjectEnd)
                    {
                        break;
                    }

                    string property = (string)reader.Value;

                    if (t_data.Properties.ContainsKey(property))
                    {
                        PropertyMetadata prop_data =
                            t_data.Properties[property];

                        if (prop_data.IsField)
                        {
                            ((FieldInfo)prop_data.Info).SetValue(
                                instance, ReadValue(prop_data.Type, reader));
                        }
                        else
                        {
                            PropertyInfo p_info =
                                (PropertyInfo)prop_data.Info;

                            if (p_info.CanWrite)
                            {
                                p_info.SetValue(
                                    instance,
                                    ReadValue(prop_data.Type, reader),
                                    null);
                            }
                            else
                            {
                                ReadValue(prop_data.Type, reader);
                            }
                        }
                    }
                    else
                    {
                        if (!t_data.IsDictionary)
                        {
                            if (!reader.SkipNonMembers)
                            {
                                throw new JsonException(String.Format(
                                                            "The type {0} doesn't have the " +
                                                            "property '{1}'",
                                                            inst_type, property));
                            }
                            else
                            {
                                ReadSkip(reader);
                                continue;
                            }
                        }

                        ((IDictionary)instance).Add(
                            property, ReadValue(
                                t_data.ElementType, reader));
                    }
                }
            }

            return(instance);
        }
예제 #51
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (this._mapElement == null)
            {
                return;
            }

            List <SystemConfig> detailsConfigs = ContainerManager.SystemConfigs.GetMapElementConfigs(this._mapElement.MapElementCategoryID, "DetailsWindow");

            MapElementCategorie mecEntity;
            string controlMode;
            string controlName;
            string displayMode;

            #region 获得配置信息
            //获得元素种类信息
            mecEntity = ContainerManager.MapElementCategorys.Where(t => t.ID == this._mapElement.MapElementCategoryID).FirstOrDefault();

            controlMode = detailsConfigs.Where(t => t.Name == "ControlMode").FirstOrDefault().Value;
            controlName = detailsConfigs.Where(t => t.Name == "ControlName").FirstOrDefault().Value;
            displayMode = detailsConfigs.Where(t => t.Name == "DisplayMode").FirstOrDefault().Value;

            #endregion

            //标题
            this.Header = mecEntity.Name + "详情";

            //控件模式
            switch (controlMode)
            {
            case "Auto":        //自动生成
                SystemConfig        itemsConfig = detailsConfigs.Where(t => t.Name == "Items").FirstOrDefault();
                List <SystemConfig> itemList    = ContainerManager.SystemConfigs.GetSystemConfigs(itemsConfig);

                if (displayMode == "Data")
                {
                    #region 数据显示模式
                    //创建详情面板
                    Grid grid = new Grid()
                    {
                        Margin = new Thickness(0, 0, 0, 8)
                    };

                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(60, GridUnitType.Pixel)
                    });
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Pixel)
                    });
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    });

                    this.Content = grid;

                    TextBlock topTextBlock = new TextBlock()
                    {
                        Margin              = new Thickness(10, 0, 0, 0),
                        FontSize            = 20,
                        Foreground          = new SolidColorBrush(Colors.Orange),
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Center
                    };
                    topTextBlock.SetValue(Grid.RowProperty, 0);

                    grid.Children.Add(topTextBlock);

                    Grid lineGrid = new Grid()
                    {
                        Background = new SolidColorBrush(Colors.Gray)
                    };
                    lineGrid.SetValue(Grid.RowProperty, 1);

                    grid.Children.Add(lineGrid);

                    WrapPanel contentPanel = new WrapPanel()
                    {
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin = new Thickness(5, 0, 0, 0)
                    };
                    contentPanel.SetValue(Grid.RowProperty, 2);

                    grid.Children.Add(contentPanel);

                    for (int i = 0; i < itemList.Count; i++)
                    {
                        List <SystemConfig> itemConfigs = ContainerManager.SystemConfigs.GetSystemConfigs(itemList[i]);
                        string name;
                        string bindField;
                        string value;
                        double?width  = null;
                        double?height = null;

                        #region 获得配置信息
                        name      = itemConfigs.Where(t => t.Name == "Name").FirstOrDefault().Value;
                        bindField = itemConfigs.Where(t => t.Name == "BindField").FirstOrDefault().Value;
                        value     = bindField.IndexOf('.') == -1 ? ConfigHelper.GetFieldValue(this._mapElement, bindField) : ConfigHelper.GetXMLFieldValue(this._mapElement, bindField);

                        string strWidth = itemConfigs.Where(t => t.Name == "Width").FirstOrDefault().Value;

                        if (!string.IsNullOrEmpty(strWidth))
                        {
                            width = Convert.ToInt32(strWidth);
                        }

                        string strHeight = itemConfigs.Where(t => t.Name == "Height").FirstOrDefault().Value;

                        if (!string.IsNullOrEmpty(strHeight))
                        {
                            height = Convert.ToInt32(strHeight);
                        }
                        #endregion

                        if (i == 0)
                        {
                            topTextBlock.Text = value;
                        }
                        else
                        {
                            TZPanelItem itemControl = new TZPanelItem()
                            {
                                NameText            = name,
                                ValueText           = value,
                                Margin              = new Thickness(0, 0, 5, 0),
                                HorizontalAlignment = HorizontalAlignment.Left
                            };

                            if (width != null)
                            {
                                itemControl.Width = (double)width;
                            }

                            if (height != null)
                            {
                                itemControl.Height = (double)height;
                            }

                            contentPanel.Children.Add(itemControl);
                        }
                    }
                    #endregion
                }
                else if (displayMode == "Avatar")
                {
                    #region 头像显示模式
                    //创建详情面板
                    Grid grid = new Grid()
                    {
                        Margin = new Thickness(5, 8, 0, 8)
                    };

                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(100, GridUnitType.Pixel)
                    });
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    });

                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(5, GridUnitType.Star)
                    });
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(5, GridUnitType.Star)
                    });

                    this.Content = grid;


                    StackPanel topPanel = new StackPanel()
                    {
                        VerticalAlignment = VerticalAlignment.Center
                    };

                    topPanel.SetValue(Grid.RowProperty, 0);
                    topPanel.SetValue(Grid.ColumnProperty, 1);
                    grid.Children.Add(topPanel);

                    //创建头像
                    Image avatarImage = new Image()
                    {
                        Stretch             = Stretch.Uniform,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(0, 0, 5, 0)
                    };

                    string imageUrl = this._mapElement.Avatar;

                    if (string.IsNullOrEmpty(imageUrl))
                    {
                        imageUrl = "/Techzen.ICS.CS;component/Images/default_picture.jpg";
                    }
                    else
                    {
                        ConfigHelper.ProcessImageUrl(ref imageUrl);
                    }

                    avatarImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(imageUrl, UriKind.RelativeOrAbsolute));

                    avatarImage.SetValue(Grid.RowProperty, 0);
                    avatarImage.SetValue(Grid.ColumnProperty, 0);
                    grid.Children.Add(avatarImage);

                    WrapPanel contentPanel = new WrapPanel();

                    contentPanel.SetValue(Grid.RowProperty, 1);
                    contentPanel.SetValue(Grid.ColumnSpanProperty, 2);
                    grid.Children.Add(contentPanel);

                    for (int i = 0; i < itemList.Count; i++)
                    {
                        List <SystemConfig> itemConfigs = ContainerManager.SystemConfigs.GetSystemConfigs(itemList[i]);
                        string name;
                        string bindField;
                        string value;
                        double?width  = null;
                        double?height = null;

                        #region 获得配置信息
                        name      = itemConfigs.Where(t => t.Name == "Name").FirstOrDefault().Value;
                        bindField = itemConfigs.Where(t => t.Name == "BindField").FirstOrDefault().Value;
                        value     = bindField.IndexOf('.') == -1 ? ConfigHelper.GetFieldValue(this._mapElement, bindField) : ConfigHelper.GetXMLFieldValue(this._mapElement, bindField);

                        string strWidth = itemConfigs.Where(t => t.Name == "Width").FirstOrDefault().Value;

                        if (!string.IsNullOrEmpty(strWidth))
                        {
                            width = Convert.ToInt32(strWidth);
                        }

                        string strHeight = itemConfigs.Where(t => t.Name == "Height").FirstOrDefault().Value;

                        if (!string.IsNullOrEmpty(strHeight))
                        {
                            height = Convert.ToInt32(strHeight);
                        }
                        #endregion

                        TZPanelItem itemControl = new TZPanelItem()
                        {
                            NameText            = name,
                            ValueText           = value,
                            HorizontalAlignment = HorizontalAlignment.Left,
                            Margin = new Thickness(0, 0, 5, 0)
                        };

                        if (width != null)
                        {
                            itemControl.Width = (double)width;
                        }

                        if (height != null)
                        {
                            itemControl.Height = (double)height;
                        }

                        if (i < 3)
                        {
                            topPanel.Children.Add(itemControl);
                        }
                        else
                        {
                            contentPanel.Children.Add(itemControl);
                        }
                    }
                    #endregion
                }
                break;

            case "Custom":      //自定义
                UIElement    customControl = Activator.CreateInstance(Type.GetType(controlName)) as UIElement;
                PropertyInfo propInfo      = customControl.GetType().GetProperty("MapElement");
                propInfo.SetValue(customControl, this._mapElement, null);
                this.Content = customControl;
                break;
            }
        }
예제 #52
0
        /// <summary>
        /// Returns the value of property 'prop' of object 'obj' which has type 'type'
        /// </summary>
        /// <param name="type">The type of 'obj'</param>
        /// <param name="obj">The object containing 'prop'</param>
        /// <param name="prop">The property name</param>
        /// <returns>The property value</returns>
        public object GetAs(Type type, object obj, string prop)
        {
            PropertyInfo propInfo = type.GetProperty(prop, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            return(propInfo.GetValue(obj, null));
        }
예제 #53
0
        public static void GenerateDynamicObjectFromString<U>(U entity, ref U result, string column)
            where U : class, new()
        {
            string columnName = column;
            if (columnName.Contains('.'))
            {
                columnName = columnName.Split('.').ElementAt(0);
            }



            PropertyInfo property = typeof(U).GetProperty(columnName);
            var properties = typeof(U).GetProperties();
            if (property != null)
            {
                object value = property.GetValue(entity);
                Type valueType = property.PropertyType;

                if (valueType.Namespace == "System" && property.GetSetMethod() != null)
                {
                    property.SetValue(result, value);
                }
                else if (value != null && valueType.GetInterface("IEnumerable") != null)
                {
                    IEnumerable<object> subValueList = value as IEnumerable<object>;
                    Type subValueType = valueType.GetGenericArguments().Single();

                    if (subValueList != null && subValueList.Count() > 0)
                    {

                        var subResultList = property.GetValue(result);

                        if (subResultList == null)
                        {
                            ConstructorInfo listconstructor = typeof(List<>).MakeGenericType(subValueType).GetConstructor(new Type[] { });
                            var test = listconstructor.Invoke(null);
                            subResultList = listconstructor.Invoke(null);
                        }

                        MethodInfo countMethod = subResultList.GetType().GetMethod("get_Count");
                        int? subResultListCount = countMethod.Invoke(subResultList, null) as int?;

                        if (subResultListCount.HasValue == false)
                        {
                            throw new ApplicationException("Error Generic Search GenerateDynamicObject : subResultListCount is null");
                        }

                        if (subResultListCount == 0)
                        {
                            ConstructorInfo subResultConstructor = subValueType.GetConstructor(new Type[] { });
                            var addMethods = subResultList.GetType().GetMethods();
                            MethodInfo addMethod = subResultList.GetType().GetMethod("Add");

                            for (int i = 0; i < subValueList.Count(); i++)
                            {
                                var subresult = subResultConstructor.Invoke(null);
                                addMethod.Invoke(subResultList, new[] { subresult });
                            }
                        }

                        MethodInfo elementAtMethod = typeof(Enumerable).GetMethod("ElementAt").MakeGenericMethod(subValueType);

                        for (int i = 0; i < subValueList.Count(); i++)
                        {
                            var valueItem = subValueList.ElementAt(i);
                            var subResult = elementAtMethod.Invoke(subResultList, new object[] { subResultList, i });
                            MethodInfo generateDynamicObjectFromSColumnsMethod = typeof(DataTable).GetMethod("GenerateDynamicObjectFromString").MakeGenericMethod(subValueType);
                            generateDynamicObjectFromSColumnsMethod.Invoke(null, new[] { valueItem, subResult, column.Substring(column.IndexOf('.') + 1) });
                        }

                        property.SetValue(result, subResultList);
                    }
                }
                else if (value != null && property.GetSetMethod() != null)
                {
                    var subResult = property.GetValue(result);
                    if (subResult == null)
                    {
                        ConstructorInfo subResultConstructor = valueType.GetConstructor(new Type[] { });
                        subResult = subResultConstructor.Invoke(null);
                    }

                    MethodInfo generateDynamicObjectFromSColumnsMethod = typeof(DataTable).GetMethod("GenerateDynamicObjectFromString").MakeGenericMethod(valueType);
                    generateDynamicObjectFromSColumnsMethod.Invoke(null, new[] { value, subResult, column.Substring(column.IndexOf('.') + 1) });
                    property.SetValue(result, subResult);
                }
            }
        }
예제 #54
0
        public string yeniProje(int firma_id, HttpRequestBase Request)
        {
            try
            {
                vrlfgysdbEntities db = new vrlfgysdbEntities();

                int vid = 1;
                if (db.proje_surec.Count() != 0)
                {
                    vid = db.proje_surec.Max(e => e.vid) + 1;
                }
                int sort = 1;
                if (db.proje_surec.Count() != 0)
                {
                    sort = db.proje_surec.Max(e => e.sort) + 1;
                }

                proje_surec prj = new proje_surec();
                foreach (var property in prj.GetType().GetProperties())
                {
                    try
                    {
                        var response = Request[property.Name];
                        if (response == null && property.PropertyType != typeof(int))
                        {
                            if (response == null)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            PropertyInfo propertyS = prj.GetType().GetProperty(property.Name);
                            if (property.PropertyType == typeof(decimal))
                            {
                                propertyS.SetValue(prj, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                            }
                            else if (property.PropertyType == typeof(int))
                            {
                                if (response == null)
                                {
                                    propertyS.SetValue(prj, Convert.ChangeType(0, property.PropertyType), null);
                                }
                                else
                                {
                                    propertyS.SetValue(prj, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                                }
                            }
                            else
                            {
                                propertyS.SetValue(prj, Convert.ChangeType(response, property.PropertyType), null);
                            }
                        }
                    }
                    catch (Exception)
                    { }
                }

                string      strImageName = StringFormatter.OnlyEnglishChar(prj.isim);
                string      createdUrl   = strImageName;
                string      tempUrl      = createdUrl;
                bool        bulundu      = false;
                int         i            = 0;
                proje_surec pg           = new proje_surec();
                do
                {
                    pg = db.proje_surec.Where(e => e.url.Equals(tempUrl)).FirstOrDefault();
                    if (pg != null)
                    {
                        tempUrl = tempUrl + i.ToString();
                    }
                    else
                    {
                        createdUrl = tempUrl;
                        bulundu    = true;
                    }
                    i++;
                } while (!bulundu);
                prj.url      = createdUrl;
                prj.firma_id = firma_id;

                prj.flag    = durumlar.aktif;
                prj.date    = DateTime.Now;
                prj.vid     = vid;
                prj.ekleyen = GetCurrentUser.GetUser().id;
                prj.sort    = sort;
                //prj.donem_sayisi = 0;
                prj.parent_vid = 0;
                prj.durum      = TamamlamaDurumlari.bekliyor;
                //prj.periyot_suresi = 0;
                prj.periyot_turu      = 0;
                prj.mevcut_donem      = 0;
                prj.tur               = ProjeSurecTur.proje;
                prj.tamamlanma_tarihi = DateTime.Now;

                string          isimControl   = "select * from proje_surec where tur = " + ProjeSurecTur.proje + " and flag != " + durumlar.silindi.ToString() + " and isim = '" + prj.isim + "' and firma_id = " + prj.firma_id;
                ProjeSurecModel isimKontrolPs = db.Database.SqlQuery <ProjeSurecModel>(isimControl).FirstOrDefault();
                if (isimKontrolPs != null)
                {
                    return("proje_isim_hatasi");
                }

                bool kullaniciKontrol = firmaProjeKontrol(prj.firma_id, prj.id).Result;
                if (!kullaniciKontrol)
                {
                    return("proje_sayisi_hatasi");
                }

                db.proje_surec.Add(prj);
                db.SaveChanges();

                /*int musteri_id = Convert.ToInt32(Request["musteri_id"].ToString());
                 * if (musteri_id != 0)
                 * {
                 *  proje_surec dbPs = db.proje_surec.Where(e => e.vid == prj.vid).FirstOrDefault();
                 *  proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault();
                 *  if (pm == null)
                 *  {
                 *      pm = new proje_musteri();
                 *      pm.date = DateTime.Now;
                 *      pm.flag = durumlar.aktif;
                 *      pm.musteri_id = musteri_id;
                 *      pm.proje_id = dbPs.id;
                 *      int vidPm = 1;
                 *      if (db.proje_musteri.Count() != 0)
                 *      {
                 *          vidPm = db.proje_musteri.Max(e => e.vid) + 1;
                 *      }
                 *      int sortPm = 1;
                 *      if (db.proje_musteri.Count() != 0)
                 *      {
                 *          sortPm = db.proje_musteri.Max(e => e.sort) + 1;
                 *      }
                 *      pm.sort = sortPm;
                 *      pm.vid = vidPm;
                 *      db.proje_musteri.Add(pm);
                 *      db.SaveChanges();
                 *  }
                 *  else if (pm != null && pm.musteri_id != musteri_id)
                 *  {
                 *      pm.musteri_id = musteri_id;
                 *      db.Entry(pm).State = EntityState.Modified;
                 *      db.SaveChanges();
                 *  }
                 * }
                 * else if (musteri_id == 0)
                 * {
                 *  proje_surec dbPs = db.proje_surec.Where(e => e.vid == prj.vid).FirstOrDefault();
                 *  proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault(); if (pm != null && pm.musteri_id != musteri_id)
                 *      if (pm != null)
                 *      {
                 *          pm.flag = durumlar.silindi;
                 *          db.Entry(pm).State = EntityState.Modified;
                 *          db.SaveChanges();
                 *      }
                 * }*/

                return(prj.url);
            }
            catch (Exception e)
            {
                return("");
            }
        }
예제 #55
0
 public CustomXamlMember(PropertyInfo propertyInfo, XamlSchemaContext schemaContext, XamlMemberInvoker invoker)
     : base(propertyInfo, schemaContext, invoker)
 {
 }
 /// <summary>
 /// Configures the specified property info.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <param name="config">The config.</param>
 public void Configure(PropertyInfo propertyInfo, SitecoreIdConfiguration config)
 {
     base.Configure(propertyInfo, config);
 }
예제 #57
0
        // This method is intended as a means to detect when MemberInfos are the same,
        // modulo the fact that they can appear to have different but equivalent local
        // No-PIA types. It is by the symbol table to determine whether
        // or not members have been added to an AggSym or not.
        public static bool IsEquivalentTo(this MemberInfo mi1, MemberInfo mi2)
        {
            if (mi1 == null || mi2 == null)
            {
                return mi1 == null && mi2 == null;
            }

#if UNSUPPORTEDAPI
            if (mi1 == mi2 || (mi1.DeclaringType.IsGenericallyEqual(mi2.DeclaringType) && mi1.MetadataToken == mi2.MetadataToken))
#else
            if (mi1.Equals(mi2))
#endif
            {
                return true;
            }

            if (mi1 is MethodInfo && mi2 is MethodInfo)
            {
                MethodInfo method1 = mi1 as MethodInfo;
                MethodInfo method2 = mi2 as MethodInfo;
                ParameterInfo[] pis1;
                ParameterInfo[] pis2;

                if (method1.IsGenericMethod != method2.IsGenericMethod)
                {
                    return false;
                }

                if (method1.IsGenericMethod)
                {
                    method1 = method1.GetGenericMethodDefinition();
                    method2 = method2.GetGenericMethodDefinition();

                    if (method1.GetGenericArguments().Length != method2.GetGenericArguments().Length)
                    {
                        return false; // Methods of different arity are not equivalent.
                    }
                }

                return method1 != method2
                    && method1.Name == method2.Name
                    && method1.DeclaringType.IsGenericallyEqual(method2.DeclaringType)
                    && method1.ReturnType.IsGenericallyEquivalentTo(method2.ReturnType, method1, method2)
                    && (pis1 = method1.GetParameters()).Length == (pis2 = method2.GetParameters()).Length
                    && Enumerable.All(Enumerable.Zip(pis1, pis2, (pi1, pi2) => pi1.IsEquivalentTo(pi2, method1, method2)), x => x);
            }

            if (mi1 is ConstructorInfo && mi2 is ConstructorInfo)
            {
                ConstructorInfo ctor1 = mi1 as ConstructorInfo;
                ConstructorInfo ctor2 = mi2 as ConstructorInfo;
                ParameterInfo[] pis1;
                ParameterInfo[] pis2;

                return ctor1 != ctor2
                    && ctor1.DeclaringType.IsGenericallyEqual(ctor2.DeclaringType)
                    && (pis1 = ctor1.GetParameters()).Length == (pis2 = ctor2.GetParameters()).Length
                    && Enumerable.All(Enumerable.Zip(pis1, pis2, (pi1, pi2) => pi1.IsEquivalentTo(pi2, ctor1, ctor2)), x => x);
            }

            if (mi1 is PropertyInfo && mi2 is PropertyInfo)
            {
                PropertyInfo prop1 = mi1 as PropertyInfo;
                PropertyInfo prop2 = mi2 as PropertyInfo;

                return prop1 != prop2
                    && prop1.Name == prop2.Name
                    && prop1.DeclaringType.IsGenericallyEqual(prop2.DeclaringType)
                    && prop1.PropertyType.IsGenericallyEquivalentTo(prop2.PropertyType, prop1, prop2)
                    && prop1.GetGetMethod(true).IsEquivalentTo(prop2.GetGetMethod(true))
                    && prop1.GetSetMethod(true).IsEquivalentTo(prop2.GetSetMethod(true));
            }

            return false;
        }
예제 #58
0
 public static void SetClrPropertyInfo(this EdmMember property, PropertyInfo propertyInfo)
 {
     property.GetMetadataProperties().SetClrPropertyInfo(propertyInfo);
 }
예제 #59
0
        protected override IEnumerable <object> ResolveEventTargets(IEventMessage message, object parentEntity, PropertyInfo field, IForwardingMode eventForwardingMode)
        {
            var fieldVal = field.GetValue(parentEntity);

            return(fieldVal == null?Enumerable.Empty <object>() : eventForwardingMode.FilterCandidates(message, (IEnumerable <object>)(fieldVal)));
        }
예제 #60
0
 public Attribute(PropertyInfo pi)
 {
     Name          = pi.Name;
     Type          = pi.PropertyType;
     ValueAccessor = MakePropertyAccessor <T, object>(pi);
 }