当前位置: 首页>>代码示例>>C#>>正文


C# IDataObject.GetProxyState方法代码示例

本文整理汇总了C#中IDataObject.GetProxyState方法的典型用法代码示例。如果您正苦于以下问题:C# IDataObject.GetProxyState方法的具体用法?C# IDataObject.GetProxyState怎么用?C# IDataObject.GetProxyState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataObject的用法示例。


在下文中一共展示了IDataObject.GetProxyState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergeProperties

        /// <summary>
        /// Merges static properties of DataObject.
        /// </summary>
        /// <param name="baseObject">Base DataObject to be merged.</param>
        /// <param name="mergingObject">Merging DataObject to be merged into base DataObject.</param>
        /// <param name="checkPaths">Consider paths in the merging.</param>
        private void MergeProperties(IDataObject baseObject, IDataObject mergingObject, Boolean checkPaths)
        {
            foreach (PropertyInfo propertyInfo in mergingObject.GetType().GetRuntimeProperties())
            {
                Boolean includePath = true;

                if (this.Paths != null)
                {
                    includePath = !checkPaths;

                    foreach (String path in this.Paths)
                    {
                        if (propertyInfo.Name == path)
                        {
                            includePath = true;
                        }
                    }
                }

                if ((propertyInfo.CanWrite) && (!mergingObject.GetProxyState(propertyInfo.Name)) && (includePath))
                {
                    if (IsDataList(propertyInfo.PropertyType))
                    {
                        IDataList propertyValue = (IDataList)propertyInfo.GetValue(mergingObject, new Object[] { });

                        if (propertyValue != null)
                        {
                            IDataList dataList = (IDataList)LightHouse.Elite.Core.Builder.Get(propertyValue.GetType());

                            for (int i = 0; i < propertyValue.Count; i++)
                            {
                                if (IsReferenceObject((IDataObject)propertyValue[i]))
                                {
                                    dataList.Add(GetReferencedObject((IDataObject)propertyValue[i]));
                                }
                                else
                                {
                                    IDataObject referencedObject = GetProxyObject((IDataObject)propertyValue[i]);
                                    dataList.Add(referencedObject);
                                }
                            }

                            propertyInfo.SetValue(baseObject, dataList, new Object[] { });
                        }
                    }
                    else if (IsDataObject(propertyInfo.PropertyType))
                    {
                        DataObject propertyValue = (DataObject)propertyInfo.GetValue(mergingObject, new Object[] { });

                        if (propertyValue != null)
                        {
                            if (IsReferenceObject(propertyValue))
                            {
                                // If the Object hasn't been saved, it is persisted as such to the database
                                if (String.IsNullOrEmpty(propertyValue.ID))
                                {
                                    IDataObject referencedObject = GetProxyObject(propertyValue);
                                    propertyInfo.SetValue(baseObject, referencedObject, new Object[] { });
                                }
                                else
                                {
                                    propertyInfo.SetValue(baseObject, GetReferencedObject(propertyValue), new Object[] { });
                                }
                            }
                            else
                            {
                                IDataObject referencedObject = GetProxyObject(propertyValue);
                                propertyInfo.SetValue(baseObject, referencedObject, new Object[] { });
                            }
                        }
                        else
                        {
                            propertyInfo.SetValue(baseObject, null, new Object[] { });
                        }
                    }
                    else
                    {
                        propertyInfo.SetValue(baseObject, propertyInfo.GetValue(mergingObject, new Object[] { }), new Object[] { });
                    }
                }
            }
        }
开发者ID:PongpetTurneo,项目名称:LightHouse,代码行数:88,代码来源:MergeExecutor.cs

示例2: MergeDynamicProperties

        /// <summary>
        /// Merges dynamic properties of DataObject.
        /// </summary>
        /// <param name="baseObject">Base DataObject to be merged.</param>
        /// <param name="mergingObject">Merging DataObject to be merged into base DataObject.</param>
        /// <param name="checkPaths">Consider paths in the merging.</param>
        private void MergeDynamicProperties(IDataObject baseObject, IDataObject mergingObject, Boolean checkPaths)
        {
            baseObject.DynamicType = mergingObject.DynamicType;

            DataCache dynamicCache = (DataCache)typeof(DataObject).GetTypeInfo().GetDeclaredField("dynamicCache").GetValue(mergingObject);

            foreach (KeyValuePair<String, Object> propertyValue in dynamicCache.GetObjectsInRegion("Properties"))
            {
                Boolean includePath = true;

                if (this.Paths != null)
                {
                    includePath = !checkPaths;

                    foreach (String path in this.Paths)
                    {
                        if (propertyValue.Key == path)
                        {
                            includePath = true;
                        }
                    }
                }

                if ((!mergingObject.GetProxyState(propertyValue.Key)) && (includePath))
                {
                    if (propertyValue.Value != null)
                    {
                        Type propertyType = propertyValue.Value.GetType();

                        if (IsDataList(propertyType))
                        {
                            IDataList mergingList = ((IDataList)propertyValue.Value);
                            IDataList dataList = (IDataList)LightHouse.Elite.Core.Builder.Get(propertyValue.Value.GetType());

                            for (int i = 0; i < mergingList.Count; i++)
                            {
                                IDataObject cloningObject = (IDataObject)mergingList[i];

                                if (IsReferenceObject(cloningObject))
                                {
                                    //Proxy on new generated object should be set to false, otherwise will bet unproxied on storing

                                    if (String.IsNullOrEmpty(cloningObject.ID))
                                    {
                                        IDataObject referencedObject = GetProxyObject(cloningObject);
                                        dataList.Add(referencedObject);
                                    }
                                    else
                                    {

                                        dataList.Add(GetReferencedObject(cloningObject));
                                    }
                                }
                                else
                                {
                                    IDataObject referencedObject = GetProxyObject(cloningObject);
                                    dataList.Add(referencedObject);
                                }
                            }

                            baseObject.SetProperty(propertyValue.Key, dataList);
                        }
                        else if (IsDataObject(propertyType))
                        {
                            DataObject cloningObject = ((DataObject)propertyValue.Value);

                            if (IsReferenceObject(cloningObject))
                            {
                                // If the Object hasn't been saved, it is persisted as such to the database
                                if (String.IsNullOrEmpty(cloningObject.ID))
                                {
                                    IDataObject referencedObject = GetProxyObject(cloningObject);
                                    baseObject.SetProperty(propertyValue.Key, referencedObject);
                                }
                                else
                                {
                                    baseObject.SetProperty(propertyValue.Key, GetReferencedObject(cloningObject));
                                }
                            }
                            else
                            {
                                IDataObject referencedObject = GetProxyObject(cloningObject);
                                baseObject.SetProperty(propertyValue.Key, referencedObject);
                            }
                        }
                        else
                        {
                            baseObject.SetProperty(propertyValue.Key, propertyValue.Value);
                        }
                    }
                    else
                    {
                        baseObject.SetProperty(propertyValue.Key, propertyValue.Value);
                    }
//.........这里部分代码省略.........
开发者ID:PongpetTurneo,项目名称:LightHouse,代码行数:101,代码来源:MergeExecutor.cs


注:本文中的IDataObject.GetProxyState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。