public void PropertyHelperReturnsNameCorrectly()
        {
            // Arrange
            var anonymous = new { foo = "bar" };
            PropertyInfo property = anonymous.GetType().GetProperties().First();

            // Act
            PropertyHelper helper = new PropertyHelper(property);

            // Assert
            Assert.Equal("foo", property.Name);
            Assert.Equal("foo", helper.Name);
        }
Example #2
0
        public void PropertyHelper_ReturnsValueCorrectly()
        {
            // Arrange
            var anonymous = new { bar = "baz" };
            var property = PropertyHelper.GetProperties(anonymous.GetType()).First().Property;

            // Act
            var helper = new PropertyHelper(property);

            // Assert
            Assert.Equal("bar", helper.Name);
            Assert.Equal("baz", helper.GetValue(anonymous));
        }
        public void PropertyHelperReturnsValueCorrectlyForValueTypes()
        {
            // Arrange
            var anonymous = new { foo = 32 };
            PropertyInfo property = anonymous.GetType().GetProperties().First();

            // Act
            PropertyHelper helper = new PropertyHelper(property);

            // Assert
            Assert.Equal("foo", helper.Name);
            Assert.Equal(32, helper.GetValue(anonymous));
        }
Example #4
0
        public void PropertyHelper_ReturnsNameCorrectly()
        {
            // Arrange
            var anonymous = new { foo = "bar" };
            var property = PropertyHelper.GetProperties(anonymous.GetType()).First().Property;

            // Act
            var helper = new PropertyHelper(property);

            // Assert
            Assert.Equal("foo", property.Name);
            Assert.Equal("foo", helper.Name);
        }
Example #5
0
        public void PropertyHelper_ReturnsGetterDelegate()
        {
            // Arrange
            var anonymous = new { bar = "baz" };
            var property = PropertyHelper.GetProperties(anonymous.GetType()).First().Property;

            // Act
            var helper = new PropertyHelper(property);

            // Assert
            Assert.NotNull(helper.ValueGetter);
            Assert.Equal("baz", helper.ValueGetter(anonymous));
        }
Example #6
0
 /// <summary>
 ///   Gets the name of a random application.
 /// </summary>
 /// <returns>The name.</returns>
 public static string Name()
 {
     return(ResourceCollectionCacher.GetArray(PropertyHelper.GetProperty(() => Resources.App.Name)).Random());
 }
Example #7
0
 protected virtual void OnPropertyChanged <T>(T obj, Expression <Func <T, object> > getPropertyExpression)
 {
     OnPropertyChanged(PropertyHelper.GetPropertyName(obj, getPropertyExpression));
 }
Example #8
0
        private BaseVM CreateVM(Type VMType, object Id = null, object[] Ids = null, Dictionary <string, object> values = null, bool passInit = false)
        {
            //通过反射创建ViewModel并赋值
            var    ctor = VMType.GetConstructor(Type.EmptyTypes);
            BaseVM rv   = ctor.Invoke(null) as BaseVM;

            try
            {
                rv.Session = new SessionServiceProvider(HttpContext.Session);
            }
            catch { }
            rv.ConfigInfo      = ConfigInfo;
            rv.Cache           = Cache;
            rv.LoginUserInfo   = LoginUserInfo;
            rv.DataContextCI   = ConfigInfo.ConnectionStrings.Where(x => x.Key.ToLower() == CurrentCS.ToLower()).Select(x => x.DcConstructor).FirstOrDefault();
            rv.DC              = this.DC;
            rv.MSD             = new ModelStateServiceProvider(ModelState);
            rv.FC              = new Dictionary <string, object>();
            rv.CreatorAssembly = this.GetType().AssemblyQualifiedName;
            rv.CurrentCS       = CurrentCS;
            rv.CurrentUrl      = this.BaseUrl;
            rv.WindowIds       = "";
            rv.UIService       = new DefaultUIService();
            rv.Log             = this.Log;
            rv.ControllerName  = this.GetType().FullName;
            rv.Localizer       = this.Localizer;
            if (HttpContext != null && HttpContext.Request != null)
            {
                try
                {
                    if (Request.QueryString != null)
                    {
                        foreach (var key in Request.Query.Keys)
                        {
                            if (rv.FC.Keys.Contains(key) == false)
                            {
                                rv.FC.Add(key, Request.Query[key]);
                            }
                        }
                    }
                    var f = HttpContext.Request.Form;
                    foreach (var key in f.Keys)
                    {
                        if (rv.FC.Keys.Contains(key) == false)
                        {
                            rv.FC.Add(key, f[key]);
                        }
                    }
                }
                catch { }
            }
            //如果传递了默认值,则给vm赋值
            if (values != null)
            {
                foreach (var v in values)
                {
                    PropertyHelper.SetPropertyValue(rv, v.Key, v.Value, null, false);
                }
            }
            //如果ViewModel T继承自BaseCRUDVM<>且Id有值,那么自动调用ViewModel的GetById方法
            if (Id != null && rv is IBaseCRUDVM <TopBasePoco> cvm)
            {
                cvm.SetEntityById(Id);
            }
            //如果ViewModel T继承自IBaseBatchVM<BaseVM>,则自动为其中的ListVM和EditModel初始化数据
            if (rv is IBaseBatchVM <BaseVM> temp)
            {
                temp.Ids = new string[] { };
                if (Ids != null)
                {
                    var tempids = new List <string>();
                    foreach (var iid in Ids)
                    {
                        tempids.Add(iid.ToString());
                    }
                    temp.Ids = tempids.ToArray();
                }
                if (temp.ListVM != null)
                {
                    temp.ListVM.CopyContext(rv);
                    temp.ListVM.Ids          = Ids == null ? new List <string>() : temp.Ids.ToList();
                    temp.ListVM.SearcherMode = ListVMSearchModeEnum.Batch;
                    temp.ListVM.NeedPage     = false;
                }
                if (temp.LinkedVM != null)
                {
                    temp.LinkedVM.CopyContext(rv);
                }
                if (temp.ListVM != null)
                {
                    //绑定ListVM的OnAfterInitList事件,当ListVM的InitList完成时,自动将操作列移除
                    temp.ListVM.OnAfterInitList += (self) =>
                    {
                        self.RemoveActionColumn();
                        self.RemoveAction();
                        if (temp.ErrorMessage.Count > 0)
                        {
                            self.AddErrorColumn();
                        }
                    };
                    if (temp.ListVM.Searcher != null)
                    {
                        var searcher = temp.ListVM.Searcher;
                        searcher.CopyContext(rv);
                        if (passInit == false)
                        {
                            searcher.DoInit();
                        }
                    }
                }
                temp.LinkedVM?.DoInit();
                //temp.ListVM?.DoSearch();
            }
            //如果ViewModel是ListVM,则初始化Searcher并调用Searcher的InitVM方法
            if (rv is IBasePagedListVM <TopBasePoco, ISearcher> lvm)
            {
                var searcher = lvm.Searcher;
                searcher.CopyContext(rv);
                if (passInit == false)
                {
                    //获取保存在Cookie中的搜索条件的值,并自动给Searcher中的对应字段赋值
                    string namePre      = ConfigInfo.CookiePre + "`Searcher" + "`" + rv.VMFullName + "`";
                    Type   searcherType = searcher.GetType();
                    var    pros         = searcherType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance).ToList();
                    pros.Add(searcherType.GetProperty("IsValid"));

                    Dictionary <string, string> cookieDic = HttpContext.Session.Get <Dictionary <string, string> >("SearchCondition" + searcher.VMFullName);
                    if (cookieDic != null)
                    {
                        foreach (var pro in pros)
                        {
                            var name = namePre + pro.Name;

                            if (cookieDic.ContainsKey(name) && !string.IsNullOrEmpty(cookieDic[name]))
                            {
                                try
                                {
                                    if (cookieDic[name] == "`")
                                    {
                                        pro.SetValue(searcher, null);
                                    }
                                    else
                                    {
                                        PropertyHelper.SetPropertyValue(searcher, pro.Name, cookieDic[name], null, true);
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                    searcher.DoInit();
                }
            }
            if (rv is IBaseImport <BaseTemplateVM> tvm)
            {
                var template = tvm.Template;
                template.CopyContext(rv);
                template.DoInit();
            }

            //自动调用ViewMode的InitVM方法
            if (passInit == false)
            {
                rv.DoInit();
            }
            return(rv);
        }
Example #9
0
            public void TryGetPropertyValue_ObjectNull()
            {
                object value;

                ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => PropertyHelper.TryGetPropertyValue(null, "property", out value));
            }
Example #10
0
    protected string getPriceText(object item)
    {
        REIQ.Entities.Property property = (REIQ.Entities.Property)item;

        return(PropertyHelper.GetPropertyPrice(property));
    }
Example #11
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            bool isFile = false;

            if (Field?.Name?.ToLower().EndsWith("id") == true)
            {
                var file = Field.Metadata.ContainerType.GetProperties().Where(x => x.Name.ToLower() + "id" == Field.Metadata.PropertyName.ToLower()).FirstOrDefault();
                if (file != null)
                {
                    isFile = true;
                }
            }
            if (isFile == true)
            {
                if (Field.Model != null)
                {
                    output.TagName = "a";
                    output.TagMode = TagMode.StartTagAndEndTag;
                    output.Attributes.Add("class", "layui-btn layui-btn-primary layui-btn-xs");
                    output.Attributes.Add("style", "margin:9px 0;width:unset");
                    var vm = context.Items["model"] as BaseVM;
                    if (vm != null)
                    {
                        output.Attributes.Add("href", $"/_Framework/GetFile/{Field.Model}?_DONOT_USE_CS={vm.CurrentCS}");
                    }
                    else
                    {
                        output.Attributes.Add("href", $"/_Framework/GetFile/{Field.Model}");
                    }
                    output.Content.AppendHtml("下载");
                }
                else
                {
                    output.TagName = "label";
                    output.TagMode = TagMode.StartTagAndEndTag;
                    output.Attributes.Add("class", "layui-form-label");
                    output.Attributes.Add("style", "text-align:left;padding:9px 0;width:unset");
                    output.Content.AppendHtml("无");
                }
            }
            else
            {
                output.TagName = "label";
                output.TagMode = TagMode.StartTagAndEndTag;
                output.Attributes.Add("class", "layui-form-label");
                output.Attributes.Add("style", "text-align:left;padding:9px 0;width:unset");
                var val = string.Empty;
                if (Field?.Model != null)
                {
                    if (Field.Model.GetType().IsEnumOrNullableEnum())
                    {
                        val = PropertyHelper.GetEnumDisplayName(Field.Model.GetType(), Field.Model.ToString());
                    }
                    else if (Field.Model.GetType() == typeof(DateTime) || Field.Model.GetType() == typeof(DateTime?))
                    {
                        if (string.IsNullOrEmpty(Format))
                        {
                            val = Field.Model.ToString();
                        }
                        else
                        {
                            val = (Field.Model as DateTime?).Value.ToString(Format);
                        }
                    }
                    else if (Field.Model.GetType().IsBoolOrNullableBool())
                    {
                        if ((bool?)Field.Model == true)
                        {
                            val = "是";
                        }
                        else
                        {
                            val = "否";
                        }
                    }
                    else
                    {
                        val = Field.Model.ToString();
                    }
                }
                else
                {
                    val = DisplayText;
                }
                output.Content.AppendHtml(val);
            }
            base.Process(context, output);
        }
Example #12
0
            public void IsPropertyAvailable_NotExistingProperty()
            {
                var myPropertyHelperClass = new MyPropertyHelperClass();

                Assert.AreEqual(false, PropertyHelper.IsPropertyAvailable(myPropertyHelperClass, "NotExistingProperty"));
            }
Example #13
0
        public static IEnumerable <KeyValuePair <string, string> > ToKeyValuePairs <TModel>(TModel model) where TModel : class, new()
        {
            var properties = PropertyHelper.GetProperties <TModel>();

            return(ToKeyValuePairs <TModel>(model, properties));
        }
Example #14
0
        private static LayoutRenderer ParseLayoutRenderer(ConfigurationItemFactory configurationItemFactory, SimpleStringReader stringReader)
        {
            int ch = stringReader.Read();

            Debug.Assert(ch == '{', "'{' expected in layout specification");

            string name           = ParseLayoutRendererName(stringReader);
            var    layoutRenderer = GetLayoutRenderer(configurationItemFactory, name);

            var wrappers        = new Dictionary <Type, LayoutRenderer>();
            var orderedWrappers = new List <LayoutRenderer>();

            ch = stringReader.Read();
            while (ch != -1 && ch != '}')
            {
                string parameterName = ParseParameterName(stringReader).Trim();
                if (stringReader.Peek() == '=')
                {
                    stringReader.Read(); // skip the '='
                    PropertyInfo   propertyInfo;
                    LayoutRenderer parameterTarget = layoutRenderer;

                    if (!PropertyHelper.TryGetPropertyInfo(layoutRenderer, parameterName, out propertyInfo))
                    {
                        Type wrapperType;

                        if (configurationItemFactory.AmbientProperties.TryGetDefinition(parameterName, out wrapperType))
                        {
                            LayoutRenderer wrapperRenderer;

                            if (!wrappers.TryGetValue(wrapperType, out wrapperRenderer))
                            {
                                wrapperRenderer       = configurationItemFactory.AmbientProperties.CreateInstance(parameterName);
                                wrappers[wrapperType] = wrapperRenderer;
                                orderedWrappers.Add(wrapperRenderer);
                            }

                            if (!PropertyHelper.TryGetPropertyInfo(wrapperRenderer, parameterName, out propertyInfo))
                            {
                                propertyInfo = null;
                            }
                            else
                            {
                                parameterTarget = wrapperRenderer;
                            }
                        }
                    }

                    if (propertyInfo == null)
                    {
                        ParseParameterValue(stringReader);
                    }
                    else
                    {
                        if (typeof(Layout).IsAssignableFrom(propertyInfo.PropertyType))
                        {
                            var              nestedLayout = new SimpleLayout();
                            string           txt;
                            LayoutRenderer[] renderers = CompileLayout(configurationItemFactory, stringReader, true, out txt);

                            nestedLayout.SetRenderers(renderers, txt);
                            propertyInfo.SetValue(parameterTarget, nestedLayout, null);
                        }
                        else if (typeof(ConditionExpression).IsAssignableFrom(propertyInfo.PropertyType))
                        {
                            var conditionExpression = ConditionParser.ParseExpression(stringReader, configurationItemFactory);
                            propertyInfo.SetValue(parameterTarget, conditionExpression, null);
                        }
                        else
                        {
                            string value = ParseParameterValue(stringReader);
                            PropertyHelper.SetPropertyFromString(parameterTarget, parameterName, value, configurationItemFactory);
                        }
                    }
                }
                else
                {
                    SetDefaultPropertyValue(configurationItemFactory, layoutRenderer, parameterName);
                }

                ch = stringReader.Read();
            }

            layoutRenderer = ApplyWrappers(configurationItemFactory, layoutRenderer, orderedWrappers);

            return(layoutRenderer);
        }
        public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder)
        {
            var info = (DateTimePropertyInfo)conceptInfo;

            codeBuilder.InsertCode(PropertyHelper.Format(@"{0:dd.MM.yyyy. HH:mm:ss}"), SimplePropertyCodeGenerator.AdditionalPropertiesTag, info);
        }
Example #16
0
        /// <summary>
        /// Creates an instance of <see cref="EntityNavigation"/>.
        /// </summary>
        /// <param name="genParams">Parameters for the generation of DTOs.</param>
        public EntityNavigation(XElement navigationNode, List <EntityAssociation> entitiesAssociations,
                                List <EntityKeyProperty> entitiesKeys, GenerateDTOsParams genParams)
        {
            // Set DTO Name
            string entityName = navigationNode.Parent.Attribute(EdmxNodeAttributes.EntityType_Name).Value;

            this.DTOName = Utils.ConstructDTOName(entityName, genParams);

            // Get the To Role End name
            string toRole = navigationNode.Attribute(EdmxNodeAttributes.NavigationProperty_ToRole).Value;

            // Get the Association Name
            string associationName = EdmxHelper.GetNavigationAssociationName(navigationNode);

            this.NavigationProperties = new List <EntityNavigationProperty>();

            // Find the Association
            EntityAssociation association = (
                from a in entitiesAssociations
                where (a.AssociationName == associationName) && (a.EndRoleName == toRole)
                select a
                ).FirstOrDefault();

            // Find the DTO associated keys
            IEnumerable <EntityKeyProperty> dtoToKeys = entitiesKeys.Where(k => k.DTOName == association.DTOName);

            // Get the base Property Name
            this.NavigationPropertyNameEDMX = navigationNode.Attribute(EdmxNodeAttributes.NavigationProperty_Name).Value;
            string propertyName = PropertyHelper.GetPropertyName(this.NavigationPropertyNameEDMX, entityName);

            // Set association type desired, can change if requirements are not met
            AssociationType associationTypeDesired = genParams.AssociationType;

            if (association.EndMultiplicity == EntityAssociationMultiplicity.Many)
            {
                if ((associationTypeDesired != AssociationType.ClassType) &&
                    (dtoToKeys.Count() != 1))
                {
                    // TODO: ffernandez, indicate Project-ProjectItem-Line-Column
                    VisualStudioHelper.AddToErrorList(TaskErrorCategory.Warning,
                                                      string.Format(Resources.Warning_CannotCreateNavPropManyKeyProp, this.DTOName, association.DTOName),
                                                      null, null, null, null);

                    associationTypeDesired = AssociationType.ClassType;
                }

                bool isList = true;

                if (associationTypeDesired == AssociationType.ClassType)
                {
                    // List<T> Type
                    string type = string.Format(Resources.CSharpTypeListT, association.DTOName);

                    this.NavigationProperties.Add(new EntityNavigationProperty(type, propertyName, isList,
                                                                               association.DTOName, association.EntityName, association.DTOName));
                }
                else
                {
                    // AssociationTypeEnum.KeyProperty
                    EntityKeyProperty dtoToKey = dtoToKeys.First();

                    // List<T> Type
                    string type = string.Format(Resources.CSharpTypeListT, dtoToKey.Type);

                    propertyName += (Resources.NameSeparator + dtoToKey.Name);

                    this.NavigationProperties.Add(new EntityNavigationProperty(type, propertyName, isList,
                                                                               dtoToKey.Type, association.EntityName, association.DTOName));
                }
            }
            else
            {
                // EntityAssociationMultiplicityEnum.One
                // EntityAssociationMultiplicityEnum.ZeroOrOne
                bool   isList = false;
                string listOf = null;

                if (associationTypeDesired == AssociationType.ClassType)
                {
                    this.NavigationProperties.Add(new EntityNavigationProperty(association.DTOName, propertyName, isList,
                                                                               listOf, association.EntityName, association.DTOName));
                }
                else
                {
                    // AssociationTypeEnum.KeyProperty

                    foreach (EntityKeyProperty dtoToKey in dtoToKeys)
                    {
                        string propName = (propertyName + Resources.NameSeparator + dtoToKey.Name);

                        this.NavigationProperties.Add(new EntityNavigationProperty(dtoToKey.Type, propName, isList,
                                                                                   listOf, association.EntityName, association.DTOName));
                    }
                }
            }
        }
Example #17
0
 /// <summary>
 ///   Gets a random application version.
 /// </summary>
 /// <returns>The version.</returns>
 public static string Version()
 {
     return(ResourceCollectionCacher.GetArray(PropertyHelper.GetProperty(() => Resources.App.VersionFormat)).Random().Numerify());
 }
        public JsonResult SignUp(User user, String password, String confirmPassword)
        {
            ErrorModel errorModel = new ErrorModel();

            if (ModelState.IsValid)
            {
                using (EasyFindPropertiesEntities dbCtx = new EasyFindPropertiesEntities())
                {
                    using (var dbCtxTran = dbCtx.Database.BeginTransaction())
                    {
                        try
                        {
                            if (!password.Equals(confirmPassword))
                            {
                                throw new Exception("The fields Password and Confirm Password are not equal");
                            }

                            PropertyHelper.createRolesIfNotExist();

                            var unitOfWork = new UnitOfWork(dbCtx);

                            var doesUserExist = unitOfWork.User.DoesUserExist(user.Email);

                            if (!doesUserExist)
                            {
                                user = PropertyHelper.createUser(unitOfWork, EFPConstants.UserType.Consumer, "", user.Email, user.FirstName,
                                                                 user.LastName, user.CellNum, DateTime.MinValue);

                                PropertyHelper.createUserAccount(unitOfWork, user.Email, password);
                            }

                            else
                            {
                                throw new Exception("This email address already exists");
                            }

                            unitOfWork.save();
                            dbCtxTran.Commit();
                        }
                        catch (Exception ex)
                        {
                            dbCtxTran.Rollback();

                            errorModel.hasErrors     = true;
                            errorModel.ErrorMessages = new List <string>();
                            errorModel.ErrorMessages.Add(ex.Message);
                        }
                    }
                }
            }
            else
            {
                var errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);

                errorModel.hasErrors     = true;
                errorModel.ErrorMessages = new List <string>();
                errorModel.ErrorMessages.AddRange(errors);
            }

            return(Json(errorModel));
        }
Example #19
0
 public new object this[String name]
 {
     get { return(PropertyHelper.GetProperty(name, this)); }
     set { PropertyHelper.SetProeprty(name, this, value); }
 }
Example #20
0
 public void IsPropertyAvailable_NullInput()
 {
     ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => PropertyHelper.IsPropertyAvailable(null, "PublicProperty"));
 }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionElement{TElement}" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="elementTag">The element tag.</param>
 /// <param name="property">The property.</param>
 public ArrayElement(string tag, string elementTag, PropertyInfo property)
     : base(tag, elementTag, PropertyHelper.Get(property), PropertyHelper.Set(property))
 {
 }
Example #22
0
            public void IsPropertyAvailable_ExistingProperty()
            {
                var myPropertyHelperClass = new MyPropertyHelperClass();

                Assert.AreEqual(true, PropertyHelper.IsPropertyAvailable(myPropertyHelperClass, "PublicProperty"));
            }
Example #23
0
            public void GetPropertyValue_PrivateReadProperty()
            {
                var myPropertyHelperClass = new MyPropertyHelperClass();

                ExceptionTester.CallMethodAndExpectException <CannotGetPropertyValueException>(() => PropertyHelper.GetPropertyValue(myPropertyHelperClass, "PrivateReadProperty"));
            }
Example #24
0
        private IList <Field> GetFields()
        {
            var fields = new List <Field>();

            fields.Add(new Field
            {
                IsKey = true,
                Name  = PropertyHelper.GetPropertyName <ECADocument>(x => x.Id),
                Type  = DataType.String
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Name),
                Type         = DataType.String,
                IsSearchable = true,
                IsSortable   = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.DocumentTypeName),
                Type         = DataType.String,
                IsSearchable = true,
                IsFacetable  = true
            });
            fields.Add(new Field
            {
                IsKey         = false,
                Name          = PropertyHelper.GetPropertyName <ECADocument>(x => x.DocumentTypeId),
                Type          = DataType.String,
                IsSearchable  = false,
                IsRetrievable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Description),
                Type         = DataType.String,
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Foci),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true,
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Goals),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Objectives),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Themes),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.PointsOfContact),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Regions),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true,
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Countries),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Locations),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Websites),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Addresses),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.PhoneNumbers),
                Type         = DataType.Collection(DataType.String),
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.OfficeSymbol),
                Type         = DataType.String,
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.Status),
                Type         = DataType.String,
                IsSearchable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.StartDate),
                Type         = DataType.DateTimeOffset,
                IsSearchable = false,
                IsFilterable = true
            });
            fields.Add(new Field
            {
                IsKey        = false,
                Name         = PropertyHelper.GetPropertyName <ECADocument>(x => x.EndDate),
                Type         = DataType.DateTimeOffset,
                IsSearchable = false,
                IsFilterable = true
            });
            foreach (var field in fields)
            {
                field.Name = ToCamelCase(field.Name);
            }
            return(fields);
        }
Example #25
0
            public void GetPropertyValue_PrivateWriteProperty()
            {
                var myPropertyHelperClass = new MyPropertyHelperClass();

                Assert.AreEqual(4, PropertyHelper.GetPropertyValue <int>(myPropertyHelperClass, "PrivateWriteProperty"));
            }
        /// <summary>
        /// Gets the curve.
        /// </summary>
        /// <param name="uniqueName">The uniqueName.</param>
        /// <param name="forceBootstrap">The force a bootstrap flag.</param>
        /// <returns></returns>
        public IPricingStructure GetCurve(String uniqueName, Boolean forceBootstrap)
        {
            var item = Cache.LoadItem <Market>(NameSpace + "." + uniqueName);

            if (item == null)
            {
                return(null);
            }
            var           deserializedMarket = (Market)item.Data;
            NamedValueSet properties         = item.AppProps;

            if (forceBootstrap)
            {
                properties.Set("Bootstrap", true);
            }
            //Handle rate basis curves that are dependent on another ratecurve.
            //TODO This functionality needs to be extended for calibrations (bootstrapping),
            //TODO where there is AccountReference dependency on one or more pricing structures.
            var pst = PropertyHelper.ExtractPricingStructureType(properties);

            if (pst == PricingStructureTypeEnum.RateBasisCurve)
            {
                //Get the reference curve identifier.
                var refCurveId = properties.GetValue <string>(CurveProp.ReferenceCurveUniqueId, true);
                //Load the data.
                var refItem = Cache.LoadItem <Market>(refCurveId);
                var deserializedRefCurveMarket = (Market)refItem.Data;
                var refCurveProperties         = refItem.AppProps;
                //Format the ref curve data and call the pricing structure helper.
                var refCurveFpmlTriplet =
                    new Triplet <PricingStructure, PricingStructureValuation, NamedValueSet>(
                        deserializedRefCurveMarket.Items[0],
                        deserializedRefCurveMarket.Items1[0], refCurveProperties);
                var spreadCurveFpmlTriplet =
                    new Triplet <PricingStructure, PricingStructureValuation, NamedValueSet>(deserializedMarket.Items[0],
                                                                                             deserializedMarket.Items1[0],
                                                                                             properties);
                //create and set the pricing structure
                var psBasis = Orion.CurveEngine.Factory.PricingStructureFactory.Create(Logger.Target, Cache, NameSpace, null, null, refCurveFpmlTriplet, spreadCurveFpmlTriplet);
                return(psBasis);
            }
            if (pst == PricingStructureTypeEnum.RateXccyCurve)
            {
                //Get the reference curve identifier.
                var refCurveId = properties.GetValue <string>(CurveProp.ReferenceCurveUniqueId, true);
                //Load the data.
                var refItem = Cache.LoadItem <Market>(refCurveId);
                var deserializedRefCurveMarket = (Market)refItem.Data;
                var refCurveProperties         = refItem.AppProps;
                //Get the reference curve identifier.
                var refFxCurveId = properties.GetValue <string>(CurveProp.ReferenceFxCurveUniqueId, true);
                //Load the data.
                var refFxItem = Cache.LoadItem <Market>(refFxCurveId);
                var deserializedRefFxCurveMarket = (Market)refFxItem.Data;
                var refFxCurveProperties         = refFxItem.AppProps;
                //Get the currency2 curve identifier.
                var currency2CurveId = properties.GetValue <string>(CurveProp.ReferenceCurrency2CurveId, true);
                //Load the data.
                var currency2Item = Cache.LoadItem <Market>(currency2CurveId);
                var deserializedCurrency2CurveMarket = (Market)currency2Item.Data;
                var refCurrencyCurveProperties       = currency2Item.AppProps;
                //Format the ref curve data and call the pricing structure helper.
                var refCurveFpmlTriplet =
                    new Triplet <PricingStructure, PricingStructureValuation, NamedValueSet>(
                        deserializedRefCurveMarket.Items[0],
                        deserializedRefCurveMarket.Items1[0], refCurveProperties);
                var refFxCurveFpmlTriplet =
                    new Triplet <PricingStructure, PricingStructureValuation, NamedValueSet>(
                        deserializedRefFxCurveMarket.Items[0],
                        deserializedRefFxCurveMarket.Items1[0], refFxCurveProperties);
                var currency2CurveFpmlTriplet =
                    new Triplet <PricingStructure, PricingStructureValuation, NamedValueSet>(
                        deserializedCurrency2CurveMarket.Items[0],
                        deserializedCurrency2CurveMarket.Items1[0], refCurrencyCurveProperties);
                var spreadCurveFpmlTriplet =
                    new Triplet <PricingStructure, PricingStructureValuation, NamedValueSet>(deserializedMarket.Items[0],
                                                                                             deserializedMarket.Items1[0], properties);
                //create and set the pricing structure
                var psBasis = Orion.CurveEngine.Factory.PricingStructureFactory.Create(Logger.Target, Cache, NameSpace, null, null, refCurveFpmlTriplet, refFxCurveFpmlTriplet,
                                                                                       currency2CurveFpmlTriplet, spreadCurveFpmlTriplet);
                return(psBasis);
            }
            // Create FpML pair from Market
            //
            var fpmlPair = new Pair <PricingStructure, PricingStructureValuation>(deserializedMarket.Items[0],
                                                                                  deserializedMarket.Items1[0]);
            //create and set the pricing structure
            var ps = Orion.CurveEngine.Factory.PricingStructureFactory.Create(Logger.Target, Cache, NameSpace, null, null, fpmlPair, properties);

            return(ps);
        }
Example #27
0
        private ModelExplorer CreateExplorerForProperty(
            ModelMetadata propertyMetadata, 
            PropertyHelper propertyHelper)
        {
            if (propertyHelper == null)
            {
                return new ModelExplorer(_metadataProvider, this, propertyMetadata, modelAccessor: null);
            }

            var modelAccessor = new Func<object, object>((c) =>
            {
                return c == null ? null : propertyHelper.GetValue(c);
            });

            return new ModelExplorer(_metadataProvider, this, propertyMetadata, modelAccessor);
        }
Example #28
0
 /// <summary>
 /// Determines whether PropertyName of the this instance and another specified object have the same string value.
 /// </summary>
 /// <typeparam name="TEntity">The type of the entity (interface or class).</typeparam>
 /// <param name="expression">The expression returning the entity property, in the form x =&gt; x.Id</param>
 /// <returns>true or false</returns>
 public bool PropertyNameEquals <TEntity>(Expression <Func <TEntity, object> > expression)
 {
     return(PropertyName.Equals(PropertyHelper.Name(expression)));
 }
Example #29
0
        public static string GetSingleRowJson <T>(this IBasePagedListVM <T, BaseSearcher> self, DataRow obj, int index = 0) where T : TopBasePoco
        {
            var sb = new StringBuilder();

            //循环所有列
            sb.Append("{");
            bool containsID = false;

            foreach (var baseCol in self.GetHeaders())
            {
                foreach (var col in baseCol.BottomChildren)
                {
                    if (col.ColumnType != GridColumnTypeEnum.Normal)
                    {
                        continue;
                    }
                    if (col.Title.ToLower() == "Id")
                    {
                        containsID = true;
                    }
                    sb.Append($"\"{col.Title}\":");
                    var html = string.Empty;

                    if (col.EditType == EditTypeEnum.Text || col.EditType == null)
                    {
                        var info = obj[col.Title];

                        html = info.ToString();
                        var ptype = col.FieldType;
                        //如果列是布尔值,直接返回true或false,让ExtJS生成CheckBox
                        if (ptype == typeof(bool) || ptype == typeof(bool?))
                        {
                            if (html.ToLower() == "true")
                            {
                                html = (self as BaseVM).UIService.MakeCheckBox(true, isReadOnly: true);
                            }
                            if (html.ToLower() == "false" || html == string.Empty)
                            {
                                html = (self as BaseVM).UIService.MakeCheckBox(false, isReadOnly: true);
                            }
                        }
                        //如果列是枚举,直接使用枚举的文本作为多语言的Key查询多语言文字
                        else if (ptype.IsEnumOrNullableEnum())
                        {
                            html = PropertyHelper.GetEnumDisplayName(ptype, html);
                        }
                    }

                    html = "\"" + html.Replace(Environment.NewLine, "").Replace("\n", string.Empty).Replace("\r", string.Empty).Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
                    sb.Append(html);
                    sb.Append(",");
                }
            }
            sb.Append($"\"TempIsSelected\":\"{"0" }\"");
            if (containsID == false)
            {
                sb.Append($",\"ID\":\"{Guid.NewGuid().ToString()}\"");
            }
            // 标识当前行数据是否被选中
            sb.Append($@",""LAY_CHECKED"":false");
            sb.Append(string.Empty);
            sb.Append("}");
            return(sb.ToString());
        }
        //-------------------------------------------方法------------------------------------//

        #region CreateVM
        /// <summary>
        /// 创建一个ViewModel,将Controller层的Session,cache,DC等信息传递给ViewModel
        /// </summary>
        /// <param name="VMType">ViewModel的类</param>
        /// <param name="Id">ViewModel的Id,如果有Id,则自动获取该Id的数据</param>
        /// <param name="Ids">如果VM为BatchVM,则自动将Ids赋值</param>
        /// <param name="values"></param>
        /// <param name="passInit"></param>
        /// <returns>创建的ViewModel</returns>
        private BaseVM CreateVM(Type VMType, Guid?Id = null, Guid[] Ids = null, Dictionary <string, object> values = null, bool passInit = false)
        {
            //通过反射创建ViewModel并赋值
            var    ctor = VMType.GetConstructor(Type.EmptyTypes);
            BaseVM rv   = ctor.Invoke(null) as BaseVM;

            try
            {
                rv.Session = new SessionServiceProvider(HttpContext.Session);
            }
            catch { }
            rv.ConfigInfo      = ConfigInfo;
            rv.DataContextCI   = GlobaInfo?.DataContextCI;
            rv.DC              = this.DC;
            rv.MSD             = new ModelStateServiceProvider(ModelState);
            rv.FC              = new Dictionary <string, object>();
            rv.CreatorAssembly = this.GetType().AssemblyQualifiedName;
            rv.CurrentCS       = CurrentCS;
            rv.CurrentUrl      = this.BaseUrl;
            rv.WindowIds       = this.WindowIds;
            rv.UIService       = this.UIService;
            rv.Log             = this.Log;
            rv.ControllerName  = this.GetType().FullName;
            if (HttpContext != null && HttpContext.Request != null)
            {
                try
                {
                    if (Request.QueryString != null)
                    {
                        foreach (var key in Request.Query.Keys)
                        {
                            if (rv.FC.Keys.Contains(key) == false)
                            {
                                rv.FC.Add(key, Request.Query[key]);
                            }
                        }
                    }
                    var f = HttpContext.Request.Form;
                    foreach (var key in f.Keys)
                    {
                        if (rv.FC.Keys.Contains(key) == false)
                        {
                            rv.FC.Add(key, f[key]);
                        }
                    }
                }
                catch { }
            }
            //如果传递了默认值,则给vm赋值
            if (values != null)
            {
                foreach (var v in values)
                {
                    PropertyHelper.SetPropertyValue(rv, v.Key, v.Value, null, false);
                }
            }
            //如果ViewModel T继承自BaseCRUDVM<>且Id有值,那么自动调用ViewModel的GetById方法
            if (Id != null && rv is IBaseCRUDVM <TopBasePoco> cvm)
            {
                cvm.SetEntityById(Id.Value);
            }
            //如果ViewModel T继承自IBaseBatchVM<BaseVM>,则自动为其中的ListVM和EditModel初始化数据
            if (rv is IBaseBatchVM <BaseVM> temp)
            {
                temp.Ids = Ids;
                if (temp.ListVM != null)
                {
                    temp.ListVM.CopyContext(rv);
                    temp.ListVM.Ids          = Ids == null ? new List <Guid>() : Ids.ToList();
                    temp.ListVM.SearcherMode = ListVMSearchModeEnum.Batch;
                    temp.ListVM.NeedPage     = false;
                }
                if (temp.LinkedVM != null)
                {
                    temp.LinkedVM.CopyContext(rv);
                }
                if (temp.ListVM != null)
                {
                    //绑定ListVM的OnAfterInitList事件,当ListVM的InitList完成时,自动将操作列移除
                    temp.ListVM.OnAfterInitList += (self) =>
                    {
                        self.RemoveActionColumn();
                        self.RemoveAction();
                        if (temp.ErrorMessage.Count > 0)
                        {
                            self.AddErrorColumn();
                        }
                    };
                    temp.ListVM.DoInitListVM();
                    if (temp.ListVM.Searcher != null)
                    {
                        var searcher = temp.ListVM.Searcher;
                        searcher.CopyContext(rv);
                        if (passInit == false)
                        {
                            searcher.DoInit();
                        }
                    }
                }
                temp.LinkedVM?.DoInit();
                //temp.ListVM.DoSearch();
            }
            //如果ViewModel是ListVM,则初始化Searcher并调用Searcher的InitVM方法
            if (rv is IBasePagedListVM <TopBasePoco, ISearcher> lvm)
            {
                var searcher = lvm.Searcher;
                searcher.CopyContext(rv);
                if (passInit == false)
                {
                    searcher.DoInit();
                }
                lvm.DoInitListVM();
            }
            if (rv is IBaseImport <BaseTemplateVM> tvm)
            {
                var template = tvm.Template;
                template.CopyContext(rv);
                template.DoInit();
            }

            //自动调用ViewMode的InitVM方法
            if (passInit == false)
            {
                rv.DoInit();
            }
            return(rv);
        }
Example #31
0
 /// <summary>
 ///   Gets a random application author.
 /// </summary>
 /// <returns>The Author.</returns>
 public static string Author()
 {
     return(ResourceCollectionCacher.GetArray(PropertyHelper.GetProperty(() => Resources.App.Author)).Random().Transform(true));
 }
Example #32
0
            public void TrySetPropertyValue_PropertyNameNull()
            {
                var obj = new MyPropertyHelperClass();

                ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => PropertyHelper.TrySetPropertyValue(obj, null, null));
            }
Example #33
0
        /// <summary>
        /// 生成单条数据的Json格式
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self"></param>
        /// <param name="obj">数据</param>
        /// <param name="returnColumnObject">不在后台进行ColumnFormatInfo的转化,而是直接输出ColumnFormatInfo的json结构到前端,由前端处理,默认False</param>
        /// <param name="index">index</param>
        /// <returns>Json格式的数据</returns>
        public static string GetSingleDataJson <T>(this IBasePagedListVM <T, BaseSearcher> self, object obj, bool returnColumnObject, int index = 0) where T : TopBasePoco
        {
            var sb         = new StringBuilder();
            var RowBgColor = string.Empty;
            var RowColor   = string.Empty;

            if (!(obj is T sou))
            {
                sou = self.CreateEmptyEntity();
            }
            RowBgColor = self.SetFullRowBgColor(sou);
            RowColor   = self.SetFullRowColor(sou);
            var isSelected = self.GetIsSelected(sou);

            //循环所有列
            sb.Append("{");
            bool containsID  = false;
            bool addHiddenID = false;

            foreach (var baseCol in self.GetHeaders())
            {
                foreach (var col in baseCol.BottomChildren)
                {
                    if (col.ColumnType != GridColumnTypeEnum.Normal)
                    {
                        continue;
                    }
                    if (col.FieldName == "Id")
                    {
                        containsID = true;
                    }
                    var backColor = col.GetBackGroundColor(sou);
                    //获取ListVM中设定的单元格前景色
                    var foreColor = col.GetForeGroundColor(sou);

                    if (backColor == string.Empty)
                    {
                        backColor = RowBgColor;
                    }
                    if (foreColor == string.Empty)
                    {
                        foreColor = RowColor;
                    }
                    var style = string.Empty;
                    if (backColor != string.Empty)
                    {
                        style += $"background-color:#{backColor};";
                    }
                    if (foreColor != string.Empty)
                    {
                        style += $"color:#{foreColor};";
                    }
                    //设定列名,如果是主键ID,则列名为id,如果不是主键列,则使用f0,f1,f2...这种方式命名,避免重复
                    sb.Append($"\"{col.Field}\":");
                    var html = string.Empty;

                    if (col.EditType == EditTypeEnum.Text || col.EditType == null)
                    {
                        if (returnColumnObject == true)
                        {
                            html = col.GetText(sou, false).ToString();
                        }
                        else
                        {
                            var info = col.GetText(sou);

                            if (info is ColumnFormatInfo)
                            {
                                html = GetFormatResult(self as BaseVM, info as ColumnFormatInfo);
                            }
                            else if (info is List <ColumnFormatInfo> )
                            {
                                var temp = string.Empty;
                                foreach (var item in info as List <ColumnFormatInfo> )
                                {
                                    temp += GetFormatResult(self as BaseVM, item);
                                    temp += "&nbsp;&nbsp;";
                                }
                                html = temp;
                            }
                            else
                            {
                                html = info.ToString();
                            }
                        }

                        var ptype = col.FieldType;
                        //如果列是布尔值,直接返回true或false,让ExtJS生成CheckBox
                        if (ptype == typeof(bool) || ptype == typeof(bool?))
                        {
                            if (html.ToLower() == "true")
                            {
                                html = (self as BaseVM).UIService.MakeCheckBox(true, isReadOnly: true);
                            }
                            if (html.ToLower() == "false" || html == string.Empty)
                            {
                                html = (self as BaseVM).UIService.MakeCheckBox(false, isReadOnly: true);
                            }
                        }
                        //如果列是枚举,直接使用枚举的文本作为多语言的Key查询多语言文字
                        else if (ptype.IsEnumOrNullableEnum())
                        {
                            html = PropertyHelper.GetEnumDisplayName(ptype, html);
                        }
                        if (style != string.Empty)
                        {
                            html = $"<div style=\"{style}\">{html}</div>";
                        }
                    }
                    else
                    {
                        string val  = col.GetText(sou).ToString();
                        string name = $"{self.DetailGridPrix}[{index}].{col.Field}";
                        switch (col.EditType)
                        {
                        case EditTypeEnum.TextBox:
                            html = (self as BaseVM).UIService.MakeTextBox(name, val);
                            break;

                        case EditTypeEnum.CheckBox:
                            bool.TryParse(val, out bool nb);
                            html = (self as BaseVM).UIService.MakeCheckBox(nb, null, name, "true");
                            break;

                        case EditTypeEnum.ComboBox:
                            html = (self as BaseVM).UIService.MakeCombo(name, col.ListItems, val);
                            break;

                        default:
                            break;
                        }
                    }
                    if (string.IsNullOrEmpty(self.DetailGridPrix) == false && addHiddenID == false)
                    {
                        html       += $@"<input hidden name=""{self.DetailGridPrix}[{index}].ID"" value=""{sou.ID}""/>";
                        addHiddenID = true;
                    }

                    html = "\"" + html.Replace(Environment.NewLine, "").Replace("\n", string.Empty).Replace("\r", string.Empty).Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
                    sb.Append(html);
                    sb.Append(",");
                }
            }
            sb.Append($"\"TempIsSelected\":\"{ (isSelected == true ? "1" : "0") }\"");
            if (containsID == false)
            {
                sb.Append($",\"ID\":\"{sou.ID}\"");
            }
            // 标识当前行数据是否被选中
            sb.Append($@",""LAY_CHECKED"":{sou.Checked.ToString().ToLower()}");
            sb.Append(string.Empty);
            sb.Append("}");
            return(sb.ToString());
        }
        private static Func<object, object> CreatePropertyGetter(Type type, string propertyName)
        {
            PropertyInfo property = type.GetProperty(propertyName);

            if (property == null)
            {
                return null;
            }

            var helper = new PropertyHelper(property);

            return helper.GetValue;
        }
Example #35
0
 public void SetPropertyValue_NullInput()
 {
     ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => PropertyHelper.SetPropertyValue(null, "PublicProperty", 42));
 }
Example #36
0
            public void SetPropertyValue_NotExistingProperty()
            {
                var myPropertyHelperClass = new MyPropertyHelperClass();

                ExceptionTester.CallMethodAndExpectException <PropertyNotFoundException>(() => PropertyHelper.SetPropertyValue(myPropertyHelperClass, "NotExistingProperty", 42));
            }
Example #37
0
            public void SetPropertyValue_PrivateWriteProperty()
            {
                var myPropertyHelperClass = new MyPropertyHelperClass();

                ExceptionTester.CallMethodAndExpectException <CannotSetPropertyValueException>(() => PropertyHelper.SetPropertyValue(myPropertyHelperClass, "PrivateWriteProperty", 42));
            }
Example #38
0
	public IEnumerable Refresh() {
		properties.Clear();
		List<SerializedProperty> myProps = new List<SerializedProperty>();
		List<SerializedProperty> theirProps = new List<SerializedProperty>();
		if(GetComponent(true)) {
			mySO = new SerializedObject(GetComponent(true));
			GetProperties(myProps, mySO);
		}
		if (GetComponent(false)) {
			theirSO = new SerializedObject(GetComponent(false));
			GetProperties(theirProps, theirSO);
		}
		same = myProps.Count == theirProps.Count;
		//TODO: add assertion and unit test for this, which should never happen
		if(mine && theirs && !same)
			Debug.LogWarning("not same number of props... wtf?");
		int count = Mathf.Max(myProps.Count, theirProps.Count);
		for(int i = 0; i < count; i++) {
			SerializedProperty myProp = null;
			SerializedProperty theirProp = null;
			if(i < myProps.Count)
				myProp = myProps[i];
			if(i < theirProps.Count)
				theirProp = theirProps[i];
			if(myProp != null && myProp.name == "m_Script")
				continue;
			if(theirProp != null && theirProp.name == "m_Script")
				continue;
			PropertyHelper ph = new PropertyHelper(this, myProp, theirProp);
			foreach(IEnumerable e in ph.CheckSame())
				yield return e;
			properties.Add(ph);
			if(!ph.same)
				same = false;
		}
	}
Example #39
0
	public IEnumerable Refresh() {
		if(ObjectMerge.refreshWatch.Elapsed.TotalSeconds > ObjectMerge.maxFrameTime) {
			ObjectMerge.refreshWatch.Reset();
			yield return null;
			ObjectMerge.refreshWatch.Start();
		}
		properties.Clear();
		List<SerializedProperty> myProps = new List<SerializedProperty>();
		List<SerializedProperty> theirProps = new List<SerializedProperty>();
		if(GetComponent(true)) {
			mySO = new SerializedObject(GetComponent(true));
			GetProperties(myProps, mySO);
		}
		if(GetComponent(false)) {
			theirSO = new SerializedObject(GetComponent(false));
			GetProperties(theirProps, theirSO);
		}
		same = myProps.Count == theirProps.Count;
		if(mine && theirs && !same)
			Debug.LogWarning("not same number of props... wtf?");
		int count = Mathf.Max(myProps.Count, theirProps.Count);
		for(int i = 0; i < count; i++) {
			SerializedProperty myProp = null;
			SerializedProperty theirProp = null;
			if(i < myProps.Count)
				myProp = myProps[i];
			if(i < theirProps.Count)
				theirProp = theirProps[i];
			PropertyHelper ph = new PropertyHelper(this, myProp, theirProp);
			foreach(IEnumerable e in ph.CheckSame())
				yield return e;
			properties.Add(ph);
			if(!ph.same)
				same = false;
		}
	}