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


C# ItemIdentifier类代码示例

本文整理汇总了C#中ItemIdentifier的典型用法代码示例。如果您正苦于以下问题:C# ItemIdentifier类的具体用法?C# ItemIdentifier怎么用?C# ItemIdentifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetTagCanonicalType

        private Int16 GetTagCanonicalType(string itemName)
        {
            const int ItemCanonicalDataTypeProperty = 1;

            TreeNode rootNode = uiGroupsTab_AllFoldersTreeView.SelectedNode;
            while (rootNode.Parent != null)
            {
                rootNode = rootNode.Parent;
            }

            var opcServer = Settings.OpcServers.Where(os => rootNode.FullPath == os.ServerName).Single();
            string urlstring = opcServer.URL;
            Server server = new Server(new Factory(), new URL(urlstring));
            server.Connect();

            ItemIdentifier [] itemIdentifiers = new ItemIdentifier[] {new ItemIdentifier(itemName)};
            PropertyID[] propertyIDs = new PropertyID[] { new PropertyID(ItemCanonicalDataTypeProperty) };

            var result = server.GetProperties(itemIdentifiers, propertyIDs, true);

            server.Disconnect();

            var resultType = result[0][0].Value.GetType();
            PropertyInfo nameProperty = resultType.GetProperty("Name");
            string name = nameProperty.GetValue(result[0][0].Value, null) as string;

            switch (name.ToLower())
            {
                case "string":
                case "char":
                    return 0;
                case "int16":
                case "int32":
                case "int64":
                case "uint16":
                case "uint32":
                case "uint64":
                    return 1;
                case "boolean":
                    return 2;
                case "decimal":
                case "double":
                    return 3;
                case "datetime":
                case "datetimeoffset":
                    return 4;
                default:
                    return 0;
            }
        }
开发者ID:densem-2013,项目名称:Chron,代码行数:50,代码来源:GroupsTab.cs

示例2: ShouldExecute

        public override bool ShouldExecute(Type itemType, ItemIdentifier itemId, Resource resource, Core.Enums.ItemEvent eventType)
        {
            if (itemType == typeof(Template) && resource.PackageFromPath.ToLower().EndsWith(".master")  )
                return true;

            return false;
        }
开发者ID:jayvin,项目名称:Courier,代码行数:7,代码来源:TemplateResources.cs

示例3: PackagedResource

        public override void PackagedResource(Type itemType, ItemIdentifier itemId, Resource resource)
        {           
            {
                var item = PersistenceManager.Default.RetrieveItem<Template>(itemId);
                var encoding = Core.Settings.Encoding;

                var contents = resource.ResourceContents;
                string fileContent = string.Empty;

                if (contents == null || contents.Length <= 0)
                {
                    string p = Context.Current.MapPath(resource.PackageFromPath);

                    if (System.IO.File.Exists(p))
                    {
                        contents = System.IO.File.ReadAllBytes(p);
                        fileContent = encoding.GetString(contents);
                    }
                }
                else
                    fileContent = encoding.GetString(contents);

                if (fileContent != string.Empty)
                {

                    fileContent = ReplaceMacrosInstring(fileContent, true, item);
                    resource.ResourceContents = encoding.GetBytes(fileContent);
                }
            }
        }
开发者ID:jayvin,项目名称:Courier,代码行数:30,代码来源:MacroParameters.cs

示例4: Execute

 public override void Execute(ItemIdentifier itemId, SerializableDictionary<string, string> Parameters)
 {
     try
     {
         Cache.ClearCacheByKeySearch("UmbracoDataTypeDefinition");
     }
     catch (Exception ex)
     {
         RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "ClearDataTypeCache", ex.ToString(), LogItemEntryType.Error);
     }
 }
开发者ID:jayvin,项目名称:Courier,代码行数:11,代码来源:RefreshDataTypeCache.cs

示例5: HandlePack

        public override Item HandlePack(ItemIdentifier id)
        {
            Company item = this.DatabasePersistence.RetrieveItem<Company>(id);

            //here we could also add dependencies or resources
            //item.Resources.Add("/file/path/to/something.jpg");

            //Dependency dep = new Dependency("Something that needs to be installed before company is" "id", new Guid());
            //item.Dependencies.Add(dep);

            return item;
        }
开发者ID:jayvin,项目名称:Courier,代码行数:12,代码来源:CompanyItemProvider.cs

示例6: Packaging

        public override void Packaging(Item item)
        {
            ContentPropertyData cpd = (ContentPropertyData)item;
            foreach (var cp in cpd.Data)
            {
                if (keyValuePrevalueEditors.Values.Contains(cp.PreValueEditor.ToLower()) && cp.Value != null)
                {
                    string[] vals = cp.Value.ToString().Split(',');
                    string newVals = string.Empty;

                    ItemIdentifier itemid = new ItemIdentifier(cp.DataType.ToString(), ProviderIDCollection.dataTypeItemProviderGuid);
                    DataType dt = PersistenceManager.Default.RetrieveItem<DataType>(itemid);

                    bool nonConvert = false;
                    int convertTestVal = 0;
                    if (!int.TryParse(string.Join("", vals), out convertTestVal))
                        nonConvert = true;

                    if (dt != null)
                    {
                        foreach (string s in vals)
                        {
                            int id;
                            if (int.TryParse(s, out id))
                            {
                                if (id > 0)
                                {
                                    var val = dt.Prevalues.Where(x => x.Id == id).FirstOrDefault();
                                    if (val != null)
                                        newVals += val.Value + ",";
                                }
                            }
                            else if(dt.Prevalues.Where(x => x.Value == s).Any())
                            {
                                newVals += s + ",";
                            }
                        }

                        newVals = newVals.Trim(',');

                        //this is a nasty hack but no way around it due to the idiotic way keyvalue types can store stuff
                        if (nonConvert)
                            newVals = "¤" + newVals;

                        cp.Value = newVals;
                    }
                }
            }
        }
开发者ID:jayvin,项目名称:Courier,代码行数:49,代码来源:KeyValuePrevalueEditor.cs

示例7: Extract

        public RepositoryActionResponse Extract(string sessionKey, byte[] item, ItemIdentifier itemId, bool overwrite, string user, string pass)
        {
            //Auth login and IP
            AuthorizeClient(user, pass);

            var p = ItemProviderCollection.Instance.GetProvider(itemId.ProviderId);
            var i = p.Deserialize(itemId, item);

            if (string.IsNullOrEmpty(sessionKey))
                sessionKey = "default";

            LocalRepo.SessionKey = sessionKey;
            var status = LocalRepo.ExtractItem(i, overwrite);

            return status;
        }
开发者ID:jayvin,项目名称:Courier,代码行数:16,代码来源:CourierRepository.asmx.cs

示例8: ExtractingResource

        public override void ExtractingResource(Type itemType, ItemIdentifier itemId, Resource resource)
        { 
                var item = PersistenceManager.Default.RetrieveItem<Template>(itemId);
                var encoding = Core.Settings.Encoding;

                var contents = resource.ResourceContents;

                if (contents != null && contents.Length > 0)
                {
                    string fileContent = encoding.GetString(contents);

                    if (!string.IsNullOrEmpty(fileContent))
                    {
                        fileContent = ReplaceMacrosInstring(fileContent, false, item);
                        resource.ResourceContents = encoding.GetBytes(fileContent);
                    }
                }
            
        }
开发者ID:jayvin,项目名称:Courier,代码行数:19,代码来源:MacroParameters.cs

示例9: PackagedResource

        public override void PackagedResource(Type itemType, ItemIdentifier itemId, Resource resource)
        {
            var fileContent = ResourceAsString(resource);
                if (fileContent != string.Empty)
                {
                        //macros
                        Helpers.MacroResolver res = new Helpers.MacroResolver();
                        res.RegisterNodeDependencies = false;
                        res.RegisterMacroDependencies = false;
                        res.context = this.ExecutionContext;

                        fileContent = res.ReplaceMacroElements(fileContent, true, null);

                        //links
                        Helpers.LocalLinkResolver les = new Helpers.LocalLinkResolver();
                        les.RegisterLinksAsDependencies = false;
                        fileContent = les.ReplaceLocalLinks(fileContent, true, null);

                        resource.ResourceContents = Core.Settings.Encoding.GetBytes(fileContent);
                }
        }
开发者ID:jayvin,项目名称:Courier,代码行数:21,代码来源:TemplateResources.cs

示例10: ReindexContent

        private void ReindexContent(Guid contentGuid, ItemIdentifier itemId)
        {
            umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(contentGuid);
            if (d != null)
            {
                XmlNode n = d.ToXml(new XmlDocument(), true);
                if (n != null)
                {
                    XElement docXnode = XDocument.Parse(n.OuterXml).Root;
                    if (d.Published)
                    {
                        //only if published should it be added to indexes which doesnt support published content
                        try
                        {
                            ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                               ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                                   .Where(x => x.EnableDefaultEventHandler));
                        }
                        catch (Exception ex)
                        {
                            RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                        }
                    }

                    //add to all indexes supporting unpublished content
                    try
                    {
                        ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                           ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                               .Where(x => x.SupportUnpublishedContent
                                   && x.EnableDefaultEventHandler));
                    }
                    catch (Exception ex)
                    {
                        RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                    }
                }
            }
        }
开发者ID:jayvin,项目名称:Courier,代码行数:39,代码来源:UpdateLuceneIndexes.cs

示例11: Extracting

        public override void Extracting(Item item)
        {
            ContentPropertyData cpd = (ContentPropertyData)item;
            foreach (var cp in cpd.Data)
            {
                if (keyValuePrevalueEditors.Values.Contains(cp.PreValueEditor.ToLower()) && cp.Value != null)
                {
                    //nonConvert indicator
                    string value = cp.Value.ToString();
                    bool nonConvert = value.StartsWith("¤");
                    value = value.TrimStart('¤');

                    string[] vals = value.Split(',');
                    string newVals = string.Empty;

                    ItemIdentifier itemid = new ItemIdentifier(cp.DataType.ToString(), ProviderIDCollection.dataTypeItemProviderGuid);

                    if (nonConvert)
                        cp.Value = value.Trim(',');
                    else
                    {
                        DataType dt = PersistenceManager.Default.RetrieveItem<DataType>(itemid);
                        if (dt != null)
                        {
                            foreach (string s in vals)
                            {
                                var val = dt.Prevalues.Where(x => x.Value == s).FirstOrDefault();
                                if (val != null)
                                {
                                    newVals += val.Id.ToString() + ",";
                                }
                            }
                            cp.Value = newVals.Trim(',');
                        }
                    }
                }
            }
        }
开发者ID:jayvin,项目名称:Courier,代码行数:38,代码来源:KeyValuePrevalueEditor.cs

示例12: SelectItemUp

		void SelectItemUp ()
		{
			if (selectedItem == null || selectedItem == topItem)
				return;
			int i = SelectedCategoryIndex;
			if (selectedItem.Item > 0) {
				selectedItem = new ItemIdentifier (selectedItem.Category, selectedItem.DataSource, selectedItem.Item - 1);
				if (i > 0 && selectedItem.Equals (topItem)) {
					SelectItemUp ();
					return;
				}
			} else {
				if (i == 0) {
					selectedItem = topItem;
				} else {
					do {
						i--;
						selectedItem = new ItemIdentifier (
							results [i].Item1,
							results [i].Item2,
							Math.Min (maxItems, results [i].Item2.ItemCount) - 1
						);
						if (selectedItem.Category == topItem.Category && selectedItem.Item == topItem.Item && i > 0) {
							i--;
							selectedItem = new ItemIdentifier (
								results [i].Item1,
								results [i].Item2,
								Math.Min (maxItems, results [i].Item2.ItemCount) - 1
							);
						}
							
					} while (i > 0 && selectedItem.DataSource.ItemCount <= 0);

					if (selectedItem.DataSource.ItemCount <= 0) {
						selectedItem = topItem;
					}
				}
			}
			ShowTooltip ();
			QueueDraw ();
		}
开发者ID:KrazyPengwin,项目名称:monodevelop,代码行数:41,代码来源:SearchPopupWindow.cs

示例13: ShowResult

		void ShowResult (SearchCategory cat, ISearchDataSource result)
		{
			incompleteResults.Add (Tuple.Create (cat, result));

			incompleteResults.Sort ((x, y) => {
				return categories.IndexOf (x.Item1).CompareTo (categories.IndexOf (y.Item1));
			}
			);

			if (incompleteResults.Count == categories.Count) {
				results.Clear ();
				results.AddRange (incompleteResults);
				List<Tuple<SearchCategory, ISearchDataSource>> failedResults = null;
				topItem = null;

				for (int i = 0; i < results.Count; i++) {
					var tuple = results [i];
					try {
						if (tuple.Item2.ItemCount == 0)
							continue;
						if (topItem == null || topItem.DataSource.GetWeight (topItem.Item) < tuple.Item2.GetWeight (0))
							topItem = new ItemIdentifier(tuple.Item1, tuple.Item2, 0);
					} catch (Exception e) {
						LoggingService.LogError ("Error while showing result " + i, e);
						if (failedResults == null)
							failedResults = new List<Tuple<SearchCategory, ISearchDataSource>> ();
						failedResults.Add (results [i]);
						continue;
					}
				}
				selectedItem = topItem;

				if (failedResults != null)
					failedResults.ForEach (failedResult => results.Remove (failedResult));

				ShowTooltip ();
				isInSearch = false;
				AnimatedResize ();
			}
		}
开发者ID:KrazyPengwin,项目名称:monodevelop,代码行数:40,代码来源:SearchPopupWindow.cs

示例14: ShowResults

		void ShowResults (List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> newResults, ItemIdentifier topResult)
		{
			results = newResults;
			selectedItem = topItem = topResult;
			ShowTooltip ();
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:6,代码来源:SearchPopupWindow.cs

示例15: Update

		public void Update (SearchPopupSearchPattern pattern)
		{
			// in case of 'string:' it's not clear if the user ment 'tag:pattern'  or 'pattern:line' therefore guess
			// 'tag:', if no valid tag is found guess 'pattern:'
			if (!string.IsNullOrEmpty (pattern.Tag) && string.IsNullOrEmpty (pattern.Pattern) && !categories.Any (c => c.IsValidTag (pattern.Tag))) {
				pattern = new SearchPopupSearchPattern (null, pattern.Tag, pattern.LineNumber, pattern.Column, pattern.UnparsedPattern);
			}

			this.pattern = pattern;
			if (src != null)
				src.Cancel ();
			HideTooltip ();
			src = new CancellationTokenSource ();
			isInSearch = true;
			if (results.Count == 0) {
				QueueDraw ();
			}
			var collectors = new List<SearchResultCollector> ();
			var token = src.Token;
			foreach (var _cat in categories) {
				var cat = _cat;
				if (!string.IsNullOrEmpty (pattern.Tag) && !cat.IsValidTag (pattern.Tag))
					continue;
				var col = new SearchResultCollector (_cat);
				collectors.Add (col);
				col.Task = cat.GetResults (col, pattern, token);
			}

			Task.WhenAll (collectors.Select (c => c.Task)).ContinueWith (t => {
				if (token.IsCancellationRequested)
					return;
				var newResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> (collectors.Count);
				foreach (var col in collectors) {
					if (col.Task.IsCanceled) {
						continue;
					} else if (col.Task.IsFaulted) {
						LoggingService.LogError ($"Error getting search results for {col.Category}", col.Task.Exception);
					} else {
						newResults.Add (Tuple.Create (col.Category, col.Results));
					}
				}

				List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> failedResults = null;
				ItemIdentifier topResult = null;
				for (int i = 0; i < newResults.Count; i++) {
					var tuple = newResults [i];
					try {
						if (tuple.Item2.Count == 0)
							continue;
						if (topResult == null || topResult.DataSource [topResult.Item].Weight < tuple.Item2 [0].Weight)
							topResult = new ItemIdentifier (tuple.Item1, tuple.Item2, 0);
					} catch (Exception e) {
						LoggingService.LogError ("Error while showing result " + i, e);
						if (failedResults == null)
							failedResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> ();
						failedResults.Add (newResults [i]);
						continue;
					}
				}

				if (failedResults != null)
					failedResults.ForEach (failedResult => newResults.Remove (failedResult));

				Application.Invoke (delegate {
					ShowResults (newResults, topResult);
					isInSearch = false;
					AnimatedResize ();
				});
			}, token);
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:70,代码来源:SearchPopupWindow.cs


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