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


C# VersionCode类代码示例

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


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

示例1: Get

        /// <summary>
        /// Gets a list of variable binds.
        /// </summary>
        /// <param name="version">Protocol version.</param>
        /// <param name="endpoint">Endpoint.</param>
        /// <param name="community">Community name.</param>
        /// <param name="variables">Variable binds.</param>
        /// <param name="timeout">The time-out value, in milliseconds. The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.</param>
        /// <returns></returns>
        public static IList<Variable> Get(VersionCode version, IPEndPoint endpoint, OctetString community, IList<Variable> variables, int timeout)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }

            if (community == null)
            {
                throw new ArgumentNullException("community");
            }

            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            if (version == VersionCode.V3)
            {
                throw new NotSupportedException("SNMP v3 is not supported");
            }

            var message = new GetRequestMessage(RequestCounter.NextId, version, community, variables);
            var response = message.GetResponse(timeout, endpoint);
            var pdu = response.Pdu();
            if (pdu.ErrorStatus.ToInt32() != 0)
            {
                throw ErrorException.Create(
                    "error in response",
                    endpoint.Address,
                    response);
            }

            return pdu.Variables;
        }
开发者ID:yonglehou,项目名称:sharpsnmplib,代码行数:44,代码来源:Messenger.cs

示例2: ComputeHash

        /// <summary>
        /// Computes the hash.
        /// </summary>
        /// <param name="version">The version.</param>
        /// <param name="header">The header.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="privacy">The privacy provider.</param>
        /// <returns></returns>
        public OctetString ComputeHash(VersionCode version, Header header, SecurityParameters parameters, Scope scope, IPrivacyProvider privacy)
        {
            // TODO: make it extension method.
            if (header == null)
            {
                throw new ArgumentNullException("header");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (scope == null)
            {
                throw new ArgumentNullException("scope");
            }

            if (privacy == null)
            {
                throw new ArgumentNullException("privacy");
            }

            return OctetString.Empty;
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:34,代码来源:DefaultAuthenticationProvider.cs

示例3: PackMessage

 internal static Sequence PackMessage(VersionCode version, ISegment header, SecurityParameters parameters, ISegment scope, IPrivacyProvider privacy)
 {
     if (scope == null)
     {
         throw new ArgumentNullException("scope");
     }
     
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     
     if (header == null)
     {
         throw new ArgumentNullException("header");
     }
     
     if (privacy == null)
     {
         throw new ArgumentNullException("privacy");
     }
     
     ISnmpData[] collection = new ISnmpData[4]
                                      {
                                          new Integer32((int)version),
                                          header.GetData(version),
                                          parameters.GetData(version),
                                          privacy.Encrypt(scope.GetData(version), parameters)
                                      };
     return new Sequence(collection);
 }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:31,代码来源:SnmpMessageExtension.cs

示例4: GetResponseMessage

        public GetResponseMessage(int requestId, VersionCode version, OctetString community, ErrorCode error, int index, IList<Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }
            
            if (community == null)
            {
                throw new ArgumentNullException("community");
            }
            
            if (version == VersionCode.V3)
            {
                throw new ArgumentException("Please use overload constructor for v3", "version");
            }

            Version = version;
            Header = Header.Empty;
            Parameters = new SecurityParameters(null, null, null, community, null, null);
            GetResponsePdu pdu = new GetResponsePdu(
                requestId,
                error,
                index,
                variables);
            Scope = new Scope(pdu);
            Privacy = DefaultPrivacyProvider.DefaultPair;

            _bytes = SnmpMessageExtension.PackMessage(Version, Header, Parameters, Scope, Privacy).ToBytes();
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:30,代码来源:GetResponseMessage.cs

示例5: SecureAgentProfile

        public SecureAgentProfile(Guid id, VersionCode version, IPEndPoint agent, string agentName, string authenticationPassphrase, string privacyPassphrase, int authenticationMethod, int privacyMethod, string userName, int timeout)
            : base(id, version, agent, agentName, userName, timeout)
        {
            AuthenticationPassphrase = authenticationPassphrase;
            PrivacyPassphrase = privacyPassphrase;
            AuthenticationMethod = authenticationMethod;
            PrivacyMethod = privacyMethod;

            switch (AuthenticationMethod)
            {
                case 0:
                    _auth = DefaultAuthenticationProvider.Instance;
                    break;
                case 1:
                    _auth = new MD5AuthenticationProvider(new OctetString(AuthenticationPassphrase));
                    break;
                case 2:
                    _auth = new SHA1AuthenticationProvider(new OctetString(AuthenticationPassphrase));
                    break;
            }

            switch (PrivacyMethod)
            {
                case 0:
                    _privacy = new DefaultPrivacyProvider(_auth);
                    break;
                case 1:
                    _privacy = new DESPrivacyProvider(new OctetString(PrivacyPassphrase), _auth);
                    break;
                case 2:
                    _privacy = new AESPrivacyProvider(new OctetString(PrivacyPassphrase), _auth);
                    break;
            }
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:34,代码来源:SecureAgentProfile.cs

示例6: SetRequestMessage

        /// <summary>
        /// Creates a <see cref="SetRequestMessage"/> with all contents.
        /// </summary>
        /// <param name="requestId">The request id.</param>
        /// <param name="version">Protocol version</param>
        /// <param name="community">Community name</param>
        /// <param name="variables">Variables</param>
        public SetRequestMessage(int requestId, VersionCode version, OctetString community, IList<Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }
            
            if (community == null)
            {
                throw new ArgumentNullException("community");
            }
            
            if (version == VersionCode.V3)
            {
                throw new ArgumentException("only v1 and v2c are supported", "version");
            }
            
            Version = version;
            Header = Header.Empty;
            Parameters = SecurityParameters.Create(community);
            var pdu = new SetRequestPdu(
                requestId,
                variables);
            Scope = new Scope(pdu);
            Privacy = DefaultPrivacyProvider.DefaultPair;
 
            _bytes = this.PackMessage(null).ToBytes();
        }
开发者ID:lovmoen,项目名称:sharpsnmplib,代码行数:35,代码来源:SetRequestMessage.cs

示例7: ReportMessage

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportMessage"/> class.
        /// </summary>
        /// <param name="version">The version code.</param>
        /// <param name="header">The header.</param>
        /// <param name="parameters">The security parameters.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="privacy">The privacy provider.</param>
        /// <param name="length">The length bytes.</param>
        public ReportMessage(VersionCode version, Header header, SecurityParameters parameters, Scope scope, IPrivacyProvider privacy, byte[] length)
        {
            if (scope == null)
            {
                throw new ArgumentNullException("scope");
            }
            
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            
            if (header == null)
            {
                throw new ArgumentNullException("header");
            }
            
            if (privacy == null)
            {
                throw new ArgumentNullException("privacy");
            }
            
            if (version != VersionCode.V3)
            {
                throw new ArgumentException("only v3 is supported", "version");
            }

            Version = version;
            Header = header;
            Parameters = parameters;
            Scope = scope;
            Privacy = privacy;
            Privacy.AuthenticationProvider.ComputeHash(Version, Header, Parameters, Scope, Privacy);            
            _bytes = this.PackMessage(length).ToBytes();
        }
开发者ID:bleissem,项目名称:sharpsnmplib,代码行数:44,代码来源:ReportMessage.cs

示例8: Create

        internal static AgentProfile Create(Guid id, VersionCode version, IPEndPoint agent, string getCommunity, string setCommunity, string agentName, string authenticationPassphrase, string privacyPassphrase, int authenticationMethod, int privacyMethod, string userName, int timeout)
        {
            if (version == VersionCode.V3)
            {
                return new SecureAgentProfile(
                    id, 
                    version,
                    agent, 
                    agentName,
                    authenticationPassphrase, 
                    privacyPassphrase,
                    authenticationMethod, 
                    privacyMethod,
                    userName, 
                    timeout);
            }

            return new NormalAgentProfile(
                id, 
                version,
                agent, 
                new OctetString(getCommunity),
                new OctetString(setCommunity), 
                agentName,
                userName, 
                timeout);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:27,代码来源:AgentProfileFactory.cs

示例9: SetRequestMessage

        /// <summary>
        /// Creates a <see cref="SetRequestMessage"/> with all contents.
        /// </summary>
        /// <param name="requestId">The request id.</param>
        /// <param name="version">Protocol version</param>
        /// <param name="community">Community name</param>
        /// <param name="variables">Variables</param>
        public SetRequestMessage(int requestId, VersionCode version, OctetString community, IList<Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }
            
            if (community == null)
            {
                throw new ArgumentNullException("community");
            }
            
            if (version == VersionCode.V3)
            {
                throw new ArgumentException("only v1 and v2c are supported", "version");
            }
            
            Version = version;
            Header = Header.Empty;
            Parameters = new SecurityParameters(null, null, null, community, null, null);
            SetRequestPdu pdu = new SetRequestPdu(
                requestId,
                ErrorCode.NoError,
                0,
                variables);
            Scope = new Scope(pdu);
            Privacy = DefaultPrivacyProvider.DefaultPair;
 
            _bytes = SnmpMessageExtension.PackMessage(Version, Header, Parameters, Scope, Privacy).ToBytes();
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:37,代码来源:SetRequestMessage.cs

示例10: AgentProfile

 internal AgentProfile(Guid id, VersionCode version, IPEndPoint agent, string name, string userName, int timeout)
 {
     Timeout = timeout;
     Id = id;
     UserName = userName;
     VersionCode = version;
     Agent = agent;
     Name = name;
 }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:9,代码来源:AgentProfile.cs

示例11: SnmpPoller

        public SnmpPoller(ListView resultlist, ListView cpuresultlist)
        {
            HostName = "localhost";
            SnmpPort = 161;
            SnmpCommunity = "public";
            SnmpVersion = VersionCode.V2;
            SnmpUser = string.Empty;
            SnmpPassword = string.Empty;

            SnmpTimeout = 1000;
            SnmpRetry = 0;
            results = new ListView.ListViewItemCollection(resultlist);
            CpuResults = new ListView.ListViewItemCollection(cpuresultlist);
        }
开发者ID:arnaudcoquelet,项目名称:Genesys_DashBoard,代码行数:14,代码来源:SnmpPoller.cs

示例12: TrapV1Message

 public TrapV1Message(VersionCode version, IPAddress agent, OctetString community, ObjectIdentifier enterprise, GenericCode generic, int specific, uint time, IList<Variable> variables)
 {
     if (variables == null)
     {
         throw new ArgumentNullException("variables");
     }
     
     if (enterprise == null)
     {
         throw new ArgumentNullException("enterprise");
     }
     
     if (community == null)
     {
         throw new ArgumentNullException("community");
     }
     
     if (agent == null)
     {
         throw new ArgumentNullException("agent");
     }
     
     if (version != VersionCode.V1)
     {
         throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "TRAP v1 is not supported in this SNMP version: {0}", version), "version");
     }
     
     Version = version;
     AgentAddress = agent;
     Community = community;
     Enterprise = enterprise;
     Generic = generic;
     Specific = specific;
     TimeStamp = time;
     var pdu = new TrapV1Pdu(
         Enterprise,
         new IP(AgentAddress),
         new Integer32((int)Generic),
         new Integer32(Specific),
         new TimeTicks(TimeStamp),
         variables);
     _pdu = pdu;
     Parameters = SecurityParameters.Create(Community);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:44,代码来源:TrapV1Message.cs

示例13: TrapV1Message

        public TrapV1Message(VersionCode version, IPAddress agent, OctetString community, ObjectIdentifier enterprise, GenericCode generic, int specific, uint time, IList<Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }
            
            if (enterprise == null)
            {
                throw new ArgumentNullException("enterprise");
            }
            
            if (community == null)
            {
                throw new ArgumentNullException("community");
            }
            
            if (agent == null)
            {
                throw new ArgumentNullException("agent");
            }
            
            Version = version;
            AgentAddress = agent;
            Community = community;
            Variables = variables;
            Enterprise = enterprise;
            Generic = generic;
            Specific = specific;
            TimeStamp = time;
            TrapV1Pdu pdu = new TrapV1Pdu(
                Enterprise,
                new IP(AgentAddress),
                new Integer32((int)Generic),
                new Integer32(Specific),
                new TimeTicks(TimeStamp),
                Variables);
            Parameters = new SecurityParameters(null, null, null, Community, null, null);

            _bytes = SnmpMessageExtension.PackMessage(Version, Community, pdu).ToBytes();
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:41,代码来源:TrapV1Message.cs

示例14: ComputeHash

        /// <summary>
        /// Computes the hash.
        /// </summary>
        /// <param name="provider">The authentication provider.</param>
        /// <param name="version">The version.</param>
        /// <param name="header">The header.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="privacy">The privacy provider.</param>
        public static void ComputeHash(this IAuthenticationProvider provider, VersionCode version, Header header, SecurityParameters parameters, ISegment scope, IPrivacyProvider privacy)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            
            if (header == null)
            {
                throw new ArgumentNullException("header");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (scope == null)
            {
                throw new ArgumentNullException("scope");
            }

            if (privacy == null)
            {
                throw new ArgumentNullException("privacy");
            }

            if (provider is DefaultAuthenticationProvider)
            {
                return;
            }

            if (0 == (header.SecurityLevel & Levels.Authentication))
            {
                return;
            }

            var scopeData = privacy.GetScopeData(header, parameters, scope.GetData(version));
            parameters.AuthenticationParameters = provider.ComputeHash(version, header, parameters, scopeData, privacy, null); // replace the hash.
        }
开发者ID:bleissem,项目名称:sharpsnmplib,代码行数:49,代码来源:AuthenticationProviderExtension.cs

示例15: GetBulkRequestMessage

        /// <summary>
        /// Creates a <see cref="GetBulkRequestMessage"/> with all contents.
        /// </summary>
        /// <param name="requestId">The request ID.</param>
        /// <param name="version">Protocol version.</param>
        /// <param name="community">Community name.</param>
        /// <param name="nonRepeaters">Non-repeaters.</param>
        /// <param name="maxRepetitions">Max repetitions.</param>
        /// <param name="variables">Variables.</param>
        public GetBulkRequestMessage(int requestId, VersionCode version, OctetString community, int nonRepeaters, int maxRepetitions, IList<Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }
            
            if (community == null)
            {
                throw new ArgumentNullException("community");
            }
            
            if (version != VersionCode.V2)
            {
                throw new ArgumentException("only v2c are supported", "version");
            }

            if (nonRepeaters > variables.Count)
            {
                throw new ArgumentException("nonRepeaters should not be greater than variable count", "nonRepeaters");
            }

            if (maxRepetitions < 1)
            {
                throw new ArgumentException("maxRepetitions should be greater than 0", "maxRepetitions");
            }

            Version = version;
            Header = Header.Empty;
            Parameters = SecurityParameters.Create(community);
            var pdu = new GetBulkRequestPdu(
                requestId,
                nonRepeaters,
                maxRepetitions,
                variables);
            Scope = new Scope(pdu);
            Privacy = DefaultPrivacyProvider.DefaultPair;

            _bytes = this.PackMessage(null).ToBytes();
        }
开发者ID:lovmoen,项目名称:sharpsnmplib,代码行数:49,代码来源:GetBulkRequestMessage.cs


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