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


C# Request.AddEntity方法代码示例

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


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

示例1: FindPackage

        public void FindPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, Request request)
        {
            // Nice-to-have put a debug message in that tells what's going on.
            request.Debug("Calling '{0}::FindPackage' '{1}','{2}','{3}','{4}'", PackageProviderName, requiredVersion, minimumVersion, maximumVersion, id);

            if (name == "test") {
                // this just returns packages so we can test the calls for creating software identity objects back in the core.
                var pkg = request.YieldSoftwareIdentity("firstpackage", "first", "1.0", "multipartnumeric", "first package", "built-in", "test", "", "");
                if (pkg != null) {
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    // add a dependency to another package.
                    var link = request.AddDependency(PackageProviderName, "second", "1.1", null, null);
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    var entity = request.AddEntity("garrett", "http://fearthecowboy.com", Iso19770_2.Role.Publisher, null);
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    var icon = request.AddLink(new Uri("http://contoso.com/icon.png"), "icon", "image/icon", null, null, null, null);
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    request.AddMetadata("Something", "Shiny");
                    request.AddMetadata(pkg, "SomeKey", "SomeValue");
                    request.AddMetadata(pkg, new Uri("http://oneget.org/oneget"), "testkey", "testvalue");
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    // some expected payload data
                    var payload = request.AddPayload();
                    request.Debug("Payload:{0}", payload);
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    var dir = request.AddDirectory(payload, "installDir", "", "PROGRAMFILES", false);
                    request.Debug("Directory:{0}", dir);
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    var file = request.AddFile(dir, "foo.txt", null, null, true, 10240, "1.0");
                    request.Debug("File:{0}", file);
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    var regkey = request.AddResource(payload, "regkey");
                    request.AddMetadata(regkey, "key", "hklm/software/testing/foo");
                    request.AddMetadata(regkey, "value", "hklm/software/testing/foo");
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.
                }

                pkg = request.YieldSoftwareIdentity("secondpackage", "second", "1.1", "multipartnumeric", "second package", "built-in", "test", "", "");
                if (pkg != null) {
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    var entity = request.AddEntity("garrett", "http://fearthecowboy.com", Iso19770_2.Role.Publisher, null);
                    if (request.IsCanceled) {
                        return;
                    } // check early, check often.

                    // show some evidence (yeah, this should have been in the getinstalledpackages but ... lazy.)
                    var evidence = request.AddEvidence(DateTime.Now, "thispc");
                    request.AddProcess(evidence, "foo.exe", 100);

                    var meta = request.AddMeta(pkg);
                    request.AddMetadata(meta, "sample", "value");
                    request.AddMetadata(meta, new Uri("http://oneget.org/oneget"), "testkey", "testvalue");

                    var link = request.AddDependency(PackageProviderName, "third", "[1.0]", null, null);
                }
            }
        }
开发者ID:notgerry,项目名称:oneget,代码行数:86,代码来源:SwidTestProvider.cs


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