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


C# Service.Description方法代码示例

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


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

示例1: getServiceInfo

        private BlockingCollection<Target> getServiceInfo(Service nService)
        {

                BlockingCollection<Target> nextTargetsToAdd = new BlockingCollection<Target>();

                try
                {
                    ServiceDescription nDesc = nService.Description();
                    ActionsDescription nActions = nDesc.Actions;

                    foreach (ActionDescription nAction in nActions.Values)
                    {
                        string controlURL = "";
                        if (ControlURLs.ContainsKey(String.Concat(nService.Device.DocumentURL, nService.ServiceTypeIdentifier)))
                        {
                            controlURL = ControlURLs[String.Concat(nService.Device.DocumentURL, nService.ServiceTypeIdentifier)];
                        }
                        else
                        {
                            controlURL = GetServiceUrl(nService.Device.DocumentURL, nService.ServiceTypeIdentifier);
                            ControlURLs.Add(String.Concat(nService.Device.DocumentURL, nService.ServiceTypeIdentifier), controlURL);
                        }

                        Target thisTarget = new Target();
                        thisTarget.targetService = nService;
                        thisTarget.targetServiceDesc = nDesc;
                        thisTarget.actionDesc = nAction;
                        thisTarget.targetId = tid;
                        thisTarget.controlURL = controlURL;
                        thisTarget.documentURL = nService.Device.DocumentURL;
                        thisTarget.friendlyName = nService.Device.FriendlyName;
                        thisTarget.ServiceTypeIdentifier = nService.ServiceTypeIdentifier;
                        thisTarget.notEnum = false;

                        nextTargetsToAdd.Add(thisTarget);
                        tid++;                      
                    }
                }
                catch (System.Net.WebException ex)
                {
                    nextTargetsToAdd = new BlockingCollection<Target>();
                }
                return nextTargetsToAdd;
        }
开发者ID:nccgroup,项目名称:UPnP-Pentest-Toolkit,代码行数:44,代码来源:Form1.cs

示例2: GenerateClassFor

        /// <summary>
        /// Generates the class code for a service.
        /// </summary>
        /// <param name="service">The service to generate for.</param>
        /// <param name="className">The class name of the service or null to use the service type.</param>
        /// <param name="namespaceName">The namespace for the class.</param>
        /// <param name="classScope">The scope for the class.</param>
        /// <param name="partial">True to make the class partial, false otherwise.</param>
        /// <param name="testStateVars">
        /// True to test each state variable to ensure it is 
        /// usuable for accessing as property, false to include
        /// all state variables as properties.</param>
        /// <returns>The string representing the code for the class.</returns>
        public string GenerateClassFor(
            Service service, string className, string namespaceName,
            ClassScope classScope, bool partial, bool testStateVars)
        {
            // If classname is not specified then default to service information
            if (className == null)
                className = DefaultCodeGenClassName(service, CodeGenProvider);
            else
                // Otherwise ensure classname is Identifier compatible
                className = CodeGenProvider.CodeFriendlyIdentifier(className, false);

            StringBuilder lsbStateVarProps = new StringBuilder();
            StringBuilder lsbStateVarConversion = new StringBuilder();
            StringBuilder lsbStateVarEnums = new StringBuilder();
            StringBuilder lsbActionMethods = new StringBuilder();
            StringBuilder lsbEventHandlers = new StringBuilder();
            StringBuilder lsbEventCallers = new StringBuilder();
            StringBuilder lsbStateVarEventIntercept = new StringBuilder();
            HashSet<string> lhsEnumStateVars = new HashSet<string>();
            StringConstants lscConsts = new StringConstants(CodeGenProvider);
            Dictionary<string, string> ldStateVarTypes = new Dictionary<string,string>();

            // Get the service description
            ServiceDescription lsdDesc = service.Description();

            if (lsdDesc != null)
            {
                // Generate the state variable property declarations
                GenerateStateVarCode(
                    service, testStateVars, lscConsts, lsbStateVarProps,
                    lsbStateVarConversion, lsbStateVarEnums, lsbEventHandlers, lsbEventCallers,
                    lsbStateVarEventIntercept, lhsEnumStateVars, ldStateVarTypes, lsdDesc);

                // Generate the action methods
                GenerateActionCode(
                    lscConsts, lsbActionMethods, lhsEnumStateVars,
                    ldStateVarTypes, lsdDesc);
            }

            if (lsbStateVarEventIntercept.Length > 0)
                lsbEventCallers.Append(
                    String.Format(CodeGenProvider.StateVarChangedEventHandler, lsbStateVarEventIntercept)
                );

            return
                String.Format(
                    CodeGenProvider.ServiceBase,
                    namespaceName,
                    className,
                    service.ServiceTypeIdentifier,
                    CodeGenProvider.GenerateRegion(CodeGenProvider.PublicEnumerations, lsbStateVarEnums.ToString()),
                    (partial ? CodeGenProvider.PartialClass : String.Empty),
                    CodeGenProvider.GenerateRegion(CodeGenProvider.ProtectedMethods, lsbStateVarConversion.ToString()),
                    lsbActionMethods,
                    CodeGenProvider.GenerateRegion(CodeGenProvider.PublicProperties, lsbStateVarProps.ToString()),
                    CodeGenProvider.GenerateRegion(CodeGenProvider.ProtectedConstants, lscConsts.Definitions().ToString(), false, false),
                    CodeGenProvider.GetClassScope(classScope, CodeGenProvider.Space.ToString()),
                    CodeGenProvider.GenerateRegion(CodeGenProvider.EventHandlers, lsbEventHandlers.ToString(), true),
                    CodeGenProvider.GenerateRegion(CodeGenProvider.EventCallers, lsbEventCallers.ToString()),
                    string.Format(
                        CodeGenProvider.ServiceClassHeaderComment,
                        (service.Device != null && service.Device.RootDevice != null ? service.Device.RootDevice.FriendlyName : CodeGenProvider.Null),
                        (service.Device != null && service.Device.RootDevice != null ? service.Device.RootDevice.Type : CodeGenProvider.Null),
                        (service.Device != null && service.Device.RootDevice != null ? service.Device.RootDevice.SerialNumber : CodeGenProvider.Null),
                        (service.Device != null ? service.Device.FriendlyName : CodeGenProvider.Null),
                        (service.Device != null ? service.Device.Type : CodeGenProvider.Null),
                        service.Id, service.ServiceTypeIdentifier,
                        DateTime.Now.ToString(),
                        className,
                        namespaceName,
                        classScope.ToString(),
                        (partial ? CodeGenProvider.PartialClass : string.Empty),
                        testStateVars,
                        CodeGenProvider.ToString()
                    )
                );
        }
开发者ID:jogibear9988,项目名称:ManagedUPnP,代码行数:90,代码来源:ServiceGen.cs

示例3: AddService

        /// <summary>
        /// Adds a service to the tree view at the correct location.
        /// </summary>
        /// <param name="service">The service to add.</param>
        public void AddService(Service service)
        {
            // Get the device and device node for the service
            Device ldDevice = service.Device;
            TreeNodeCollection lnDeviceNode = GetDeviceNodeFor(service.Device);

            // Add the service node
            TreeNode lnServiceNode = AddUPnPItem(lnDeviceNode, new UPnPServiceTreeItem(service));

            // Get the service description
            ServiceDescription lsdDesc = service.Description();

            // If the description is available
            if (lsdDesc != null && mbAddServiceDetail)
            {
                // Add the actions
                if (lsdDesc.Actions.Count > 0)
                    foreach (ActionDescription laAction in lsdDesc.Actions.Values)
                        AddUPnPItem(lnServiceNode.Nodes, new UPnPActionTreeItem(service, laAction));

                // Add the state variables
                if (lsdDesc.StateVariables.Count > 0)
                    foreach (StateVariableDescription lsvVar in lsdDesc.StateVariables.Values)
                        AddUPnPItem(lnServiceNode.Nodes, new UPnPStateVarTreeItem(service, lsvVar));
            }
        }
开发者ID:jogibear9988,项目名称:ManagedUPnP,代码行数:30,代码来源:ctlUPnPTreeBrowser.cs


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