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


C# IZetboxContext.GetInterfaceType方法代码示例

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


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

示例1: AttachToContext

 public override void AttachToContext(IZetboxContext ctx, Func<IFrozenContext> lazyFrozenContext)
 {
     base.AttachToContext(ctx, lazyFrozenContext);
     if (ctx.ContainsObject(ctx.GetInterfaceType(this), this.ID) == null)
     {
         // Object is not in this Context present
         // -> Attach it. Attach will call this Method again!
         ctx.Attach(this);
     }
 }
开发者ID:daszat,项目名称:zetbox,代码行数:10,代码来源:PersistenceObjectBaseImpl.cs

示例2: LoadGuids

        private static Dictionary<Type, List<Guid>> LoadGuids(IZetboxContext ctx, IPackageProvider[] providers)
        {
            Log.Info("Loading Export Guids");

            Dictionary<Type, List<Guid>> guids = new Dictionary<Type, List<Guid>>();
            foreach (var reader in providers.Select(p => p.Reader))
            {
                XPathDocument doc = new XPathDocument(reader);
                XPathNavigator nav = doc.CreateNavigator();
                XPathNodeIterator it = nav.Select("//*[@ExportGuid]");

                while (it.MoveNext())
                {
                    string ns = it.Current.NamespaceURI;
                    string tn = it.Current.LocalName;
                    if (it.Current.MoveToAttribute("ExportGuid", String.Empty))
                    {
                        Guid exportGuid = it.Current.Value.TryParseGuidValue();
                        if (exportGuid != Guid.Empty)
                        {
                            string ifTypeName = string.Format("{0}.{1}", ns, tn);
                            ifTypeName = MigrateTypeNameMapping(ifTypeName);
                            Type t = ctx.GetInterfaceType(ifTypeName).Type;
                            if (t != null)
                            {
                                if (!guids.ContainsKey(t)) guids[t] = new List<Guid>();
                                guids[t].Add(exportGuid);
                            }
                            else
                            {
                                Log.WarnOnce(string.Format("Type {0} not found", ifTypeName));
                            }
                        }
                    }
                }
            }
            return guids;
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:38,代码来源:Importer.cs

示例3: PreFetchObjects

        private static void PreFetchObjects(IZetboxContext ctx, Dictionary<Guid, IPersistenceObject> objects, Dictionary<Type, List<Guid>> guids)
        {
            Log.Info("Prefetching Objects");
            foreach (Type t in guids.Keys)
            {
                IEnumerable<IPersistenceObject> result = ctx.FindPersistenceObjects(ctx.GetInterfaceType(t), guids[t]);
                if (Log.IsDebugEnabled)
                {
                    // avoid result.Count() evaluation if not needed
                    Log.DebugFormat("{0}: XML: {1}, Storage: {2}", t.FullName, guids[t].Count, result.Count());
                }

                foreach (IPersistenceObject obj in result)
                {
                    objects.Add(((IExportableInternal)obj).ExportGuid, obj);
                }
            }
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:18,代码来源:Importer.cs

示例4: ImportElement

        private static IPersistenceObject ImportElement(IZetboxContext ctx, Dictionary<Guid, IPersistenceObject> objects, IPackageProvider s)
        {
            Guid exportGuid = s.Reader.GetAttribute("ExportGuid").TryParseGuidValue();
            if (exportGuid != Guid.Empty)
            {
                string ifTypeName = string.Format("{0}.{1}", s.Reader.NamespaceURI, s.Reader.LocalName);
                ifTypeName = MigrateTypeNameMapping(ifTypeName);
                InterfaceType ifType = ctx.GetInterfaceType(ifTypeName);
                if (ifType.Type == null)
                {
                    Log.WarnOnce(string.Format("Type {0} not found", ifTypeName));
                    return null;
                }

                IPersistenceObject obj = FindObject(ctx, objects, exportGuid, ifType);

                using (var children = s.Reader.ReadSubtree())
                {
                    while (children.Read())
                    {
                        if (children.NodeType == XmlNodeType.Element)
                        {
                            ((IExportableInternal)obj).MergeImport(s.Reader);
                        }
                    }
                }

                if (obj is Blob && s.SupportsBlobs)
                {
                    var blob = (Blob)obj;
                    using (var stream = s.GetBlob(blob.ExportGuid))
                    {
                        blob.StoragePath = ctx.Internals().StoreBlobStream(stream, blob.ExportGuid, blob.CreatedOn, blob.OriginalName);
                    }
                }

                return obj;
            }
            else
            {
                return null;
            }
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:43,代码来源:Importer.cs


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