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


C# IEncoder类代码示例

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


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

示例1: encode

		public void encode(IEncoder enc) {
			enc.WriteStr8(PackageName) ;
			enc.WriteStr8(ClassName) ;					
			enc.WriteUint32(Hash[0]) ;
			enc.WriteUint32(Hash[1]) ;
			enc.WriteUint32(Hash[2]) ;
			enc.WriteUint32(Hash[3]) ;			
		}
开发者ID:drzo,项目名称:opensim4opencog,代码行数:8,代码来源:ClassKey.cs

示例2: TestEncoder

        private static void TestEncoder(UInt32 imageDimension, IEncoder enc)
        {
            var i = new Bitmap((int)imageDimension, (int)imageDimension, PixelFormat.Format24bppRgb);
            var g = Graphics.FromImage(i);
            g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, i.Width, i.Height);
            g.DrawEllipse(new Pen(Color.IndianRed), 1, 1, i.Width / 2, i.Height / 2);
            g.DrawRectangle(new Pen(Color.GreenYellow, 4), i.Width / 2, i.Width / 2, i.Width / 2 - 4, i.Width / 2 - 4);

            var ihdr = new Ihdr(imageDimension, imageDimension, BitDepth._8, ColorType.Rgb);
            var apng = new APNG(ihdr);
            apng.RegisterDecoder(new SimpleDecoder());
            apng.Encoder = enc;
            apng.AddDefaultImageFromObject(i);

            var frames = new Frame[i.Height / 2];

            for(int j = 0; j < i.Height / 2; j++)
                {
                var bmp = new Bitmap((int)imageDimension, (int)imageDimension, PixelFormat.Format24bppRgb);
                var gr = Graphics.FromImage(bmp);
                gr.Clear(Color.Blue);
                gr.DrawEllipse(new Pen(Color.Lime), bmp.Width / 4, j, bmp.Width / 2, bmp.Height / 2);
                frames[j] = new Frame() { Delay = new Rational(10, 100), FrameObject = bmp };
                }
            apng.SetFrames(frames);

            String fileName = String.Format("{0}_{1}x{2}_{3}.png", enc.GetType().Name, imageDimension, imageDimension, 0);

            if(File.Exists(fileName))
                File.Delete(fileName);
            apng.ToFile(fileName);

            ihdr = new Ihdr(imageDimension, imageDimension, BitDepth._8, ColorType.Rgb);
            apng = new APNG(ihdr);
            apng.RegisterDecoder(new SimpleDecoder());
            apng.Encoder = enc;

            String nowString = DateTime.UtcNow.ToString(@"yyyy\-MM\-dd HH:mm");
            g.Clear(Color.Blue);
            g.DrawString(nowString, new Font("Consolas", 7), new SolidBrush(Color.Lime), 5, i.Height / 2f);
            apng.AddDefaultImageFromObject(i);
            frames = new Frame[i.Height / 2-10];

            for(int j = 10; j < i.Height / 2; j++)
                {
                var bmp = new Bitmap((int)imageDimension, (int)imageDimension, PixelFormat.Format24bppRgb);
                var gr = Graphics.FromImage(bmp);
                gr.Clear(Color.Blue);
                gr.DrawString(nowString, new Font("Consolas", 7), new SolidBrush(Color.Lime), 5, j);
                frames[j-10] = new Frame() { Delay = new Rational(10, 100), FrameObject = bmp };
                }
            apng.SetFrames(frames);
            fileName = String.Format("{0}_{1}x{2}_{3}.png", enc.GetType().Name, imageDimension, imageDimension, 1);

            if(File.Exists(fileName))
                File.Delete(fileName);
            apng.ToFile(fileName);
        }
开发者ID:Darcara,项目名称:LibApng,代码行数:58,代码来源:Program.cs

示例3: TestInitialize

 public void TestInitialize()
 {
     _mockPort = Substitute.For<ISerialPort>();
     _mockEncoder = Substitute.For<IEncoder>();
     _arduino = new ArduinoController(_mockPort, _mockEncoder)
     {
         RodType = eRod.GoalKeeper
     };
     _arduino.MaxTicks = MAX_TICKS;
 }
开发者ID:djjosse,项目名称:Foosbot,代码行数:10,代码来源:ArduinoComTests.cs

示例4: LoadCodecs

        /// <summary>
        /// Load codecs from assembly
        /// </summary>
        /// <param name="encoder"></param>
        /// <param name="assembly"></param>
        /// <param name="typeMatch"></param>
        private static void LoadCodecs(IEncoder encoder, Assembly assembly, Regex typeMatch)
        {
            Debug.Assert(encoder != null);
            Debug.Assert(assembly != null);
            Debug.Assert(typeMatch != null);

            foreach (Type type in assembly.GetTypes()) {
                if (typeMatch.IsMatch(type.FullName)) {
                    LoadCodec(encoder, type);
                }
            }
        }
开发者ID:rsheynin,项目名称:owasp-esapi-dotnet,代码行数:18,代码来源:EsapiLoader.cs

示例5: WriteAsset

        public virtual void WriteAsset(Bundle bundle, IEncoder encoder)
        {
            response.ContentType = bundle.ContentType;
            CacheLongTime(bundle.Hash.ToHexString(), bundle.BrowserTtl);

            using (var stream = bundle.Content)
            {
                stream.CopyTo(response.OutputStream);
            }

            encoder.Encode(response);
        }
开发者ID:justin-arvay,项目名称:WebAssetBundler,代码行数:12,代码来源:ResponseWriter.cs

示例6: SocketServer

 /// <summary>
 /// 使用默认配置参数的构造函数
 /// </summary>
 /// <param name="handler"></param>
 public SocketServer(IServerHandler handler,IEncoder encoder, IDecoder decoder)
     : base(DefaultConfigure.SocketBufferSize, DefaultConfigure.MessageBufferSize)
 {
     if (handler == null) throw new ArgumentNullException("handler");
     if (encoder == null) throw new ArgumentNullException("encoder");
     if (decoder == null) throw new ArgumentNullException("decoder");
     this._handler = handler;
     this._protocol = new DefaultBinaryProtocol();
     this._encoder = encoder;
     this._decoder = decoder;
     this._maxMessageSize = DefaultConfigure.MaxMessageSize;
     this._maxConnections = DefaultConfigure.MaxConnections;
 }
开发者ID:zhujunxxxxx,项目名称:FastNetwork,代码行数:17,代码来源:SocketServer.cs

示例7: HttpRequest

        public HttpRequest(IEncoder encoder)
        {
            RawHeaders = new Dictionary<string, object>();

            ClientCertificates = new X509CertificateCollection();

            UserAgent = String.Format("EasyHttp HttpClient v{0}",
                                      Assembly.GetAssembly(typeof (HttpClient)).GetName().Version);

            Accept = String.Join(";", HttpContentTypes.TextHtml, HttpContentTypes.ApplicationXml,
                                 HttpContentTypes.ApplicationJson);
            _encoder = encoder;

            Timeout = 100000; //http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout.aspx
        }
开发者ID:hhariritests,项目名称:EasyHttp,代码行数:15,代码来源:HttpRequest.cs

示例8: LoadCodec

        /// <summary>
        /// Load codec instance
        /// </summary>
        /// <param name="encoder">Encoder instance</param>
        /// <param name="codec">Codec type</param>
        /// <returns></returns>
        private static bool LoadCodec(IEncoder encoder,Type codec)
        {
            Debug.Assert(encoder != null);
            Debug.Assert(codec != null);

            bool loaded = false;

            object[] attrs = codec.GetCustomAttributes(typeof(CodecAttribute), false);
            if (attrs != null && attrs.Length > 0) {
                CodecAttribute codecAttr = (CodecAttribute)attrs[0];

                if (codecAttr.AutoLoad) {
                    encoder.AddCodec(codecAttr.Name, ObjectBuilder.Build<ICodec>(codec));
                    loaded = true;
                }
            }

            return loaded;
        }
开发者ID:rsheynin,项目名称:owasp-esapi-dotnet,代码行数:25,代码来源:EsapiLoader.cs

示例9: ExecutionUnit

        /// <summary>
        /// Initializes a new instance of the <see cref="Computer"/> class.
        /// </summary>
        /// <param name="stack">The stack.</param>
        /// <param name="encoder">The instruction encoder.</param>
        /// <param name="decoder">The instruction decoder.</param>
        public ExecutionUnit(IStack stack, IEncoder encoder, IDecoder decoder, IArithmeticLogicUnit alu)
        {
            _context = new ExecutionContext
            {
                Stack = stack,
                Encoder = encoder,
                Decoder = decoder,
                Alu = alu,
                Executing = true
            };

            _dispatcher = new Dictionary<InstructionType, Action<ExecutionContext, Instruction>>
            {
                { InstructionType.Mult, Multiply.GetAction() },
                { InstructionType.Call, Call.GetAction() },
                { InstructionType.Ret, Return.GetAction() },
                { InstructionType.Stop, Stop.GetAction() },
                { InstructionType.Print, Print.GetAction() },
                { InstructionType.Push, Push.GetAction() }
            };
        }
开发者ID:hkra,项目名称:Computer,代码行数:27,代码来源:ExecutionUnit.cs

示例10: ConversionManager

 public ConversionManager(IResourceHandler fileHandler, IResourceHandler registryHandler, IEncoder encoder)
 {
     _fileHandler = fileHandler;
     _registryHandler = registryHandler;
     _encoder = encoder;
 }
开发者ID:binglot,项目名称:Bin2Reg,代码行数:6,代码来源:ConversionManager.cs

示例11: HttpClient

        public HttpClient(IContainerConfiguration containerConfiguration)
        {
            var registry = containerConfiguration.InitializeContainer();

            ObjectFactory.Initialize(x => x.AddRegistry(registry));

            _encoder = ObjectFactory.GetInstance<IEncoder>();
            _decoderFactory = ObjectFactory.GetInstance<IDecoderFactory>();

            Request = new HttpRequest(_encoder);
        }
开发者ID:HEskandari,项目名称:EasyHttp,代码行数:11,代码来源:HttpClient.cs

示例12: Encode

        public virtual void Encode(IEncoder encoder) {
            encoder.PushNamespace("http://opcfoundation.org/UA/2008/02/Types.xsd");
			encoder.WriteEncodable<ResponseHeader>("ResponseHeader", ResponseHeader);
			encoder.WriteEncodableArray<EndpointDescription>("Endpoints", Endpoints);
            encoder.PopNamespace();
        }
开发者ID:yuriik83,项目名称:workstation-uaclient,代码行数:6,代码来源:Types.generated.cs

示例13: HttpClient

        public HttpClient(IEncoderDecoderConfiguration encoderDecoderConfiguration)
        {
            _encoder = encoderDecoderConfiguration.GetEncoder();
            _decoder = encoderDecoderConfiguration.GetDecoder();
            _decoder.ShouldRemoveAtSign = ShouldRemoveAtSign;
            _uriComposer = new UriComposer();

            Request = new HttpRequest(_encoder);
        }
开发者ID:Vittel,项目名称:Trakkr,代码行数:9,代码来源:HttpClient.cs

示例14: EncodeValue

		public void EncodeValue(IEncoder enc, short type, object val) {
			try {
			 	switch ((int)type) {
			 		case 1: enc.WriteUint8((short) val) ; break;       // U8
			 		case 2: enc.WriteUint16((int) val) ;  break;       // U16     
			 		case 3: enc.WriteUint32((long) val) ; break;       // U32
			 		case 4: enc.WriteUint64((long) val) ; break;       // U64 
			 		case 6: enc.WriteStr8((string) val) ; break;       // SSTR
			 		case 7: enc.WriteStr16((string) val) ; break;      // LSTR
			 		case 8: enc.WriteDatetime((long) val); break;	   // ABSTIME
			 		case 9: enc.WriteUint32((long) val);   break;      // DELTATIME
			 		case 10: ((ObjectID)val).encode(enc) ; break;	   // ref
			 		case 11: 
			 			if ((bool) val) {
			 				enc.WriteUint8(1) ;
			 			} else {
			 				enc.WriteUint8(0) ;
			 			}
			 			break ;
			 		case 12: enc.WriteFloat((float) val); break;	   // FLOAT
			 		case 13: enc.WriteDouble((double) val);   break;   // DOUBLE			 			
			 		case 14: enc.WriteUuid((UUID) val) ; break ;	   // UUID		
			 		case 15: enc.WriteMap((Dictionary<string, object>) val) ; break ;  // Ftable
			 		case 16: enc.WriteInt8((short) val) ; break;       // int8
			 		case 17: enc.WriteInt16((int) val) ;  break;       // int16     
			 		case 18: enc.WriteInt32(long.Parse(""+ val)) ; break;       // int32
			 		case 19: enc.WriteInt64(long.Parse("" + val)) ; break;       // int64 
			 		case 20: 									       // Object
			 			// Check that the object has a session, if not
			 			// take ownership of it
			 			QMFObject qObj = (QMFObject) val ;
			 			if (qObj.Session == null) {
			 				qObj.Session = this ;
			 			}
			 			qObj.Encode(enc) ; 
			 			break;      
			 		case 21:                                             // List	
			 			List<object> items = (List<object>) val ;
			 			MSEncoder lEnc = new MSEncoder(1) ;
			 			lEnc.Init() ;			 			
			 			lEnc.WriteUint32(items.Count) ;
			 			foreach (object obj in items) {
			 				short innerType = Util.QMFType(obj) ;
			 				lEnc.WriteUint8(innerType) ;
			 				this.EncodeValue(lEnc,innerType,obj) ;		 				
			 			}
			 			enc.WriteVbin32(lEnc.Segment().ToArray()) ;
			 			break ;
			 		case 22:							                 // Array
			 			List<object> aItems = (List<object>) val ;
			 			MSEncoder aEnc = new MSEncoder(1) ;
			 			aEnc.Init() ;			 						 			
			 			long aCount = aItems.Count ;	 			
			 			aEnc.WriteUint32(aCount) ;
			 			if (aCount > 0) {
			 				Object anObj = aItems[0] ;
			 				short innerType = Util.QMFType(anObj) ;
				 			aEnc.WriteUint8(innerType) ;
				 			foreach (object obj in aItems) {
				 				this.EncodeValue(aEnc,innerType,obj) ;		 				
				 			}
			 			}
			 			enc.WriteVbin32(aEnc.Segment().ToArray()) ;			 			
			 			break ;
			 		default: 
			 			throw new Exception(String.Format("Invalid Type Code: {0}", type)) ;			 			
			 	}	
			 }
			 catch (System.InvalidCastException e) {
			 	string msg = String.Format("Class cast exception for typecode {0}, type {1} ", type, val.GetType()) ;
			 	log.Error(msg) ;
			 	throw new Exception(msg + type, e) ;
			 }
		 }				 
开发者ID:drzo,项目名称:opensim4opencog,代码行数:74,代码来源:Session.cs

示例15: Encode

		public void Encode (IEncoder enc) {
			int mask = 0 ;
			int bit = 0 ;
			List<SchemaProperty> propsToEncode = new List<SchemaProperty>() ;
			log.Debug(String.Format("Encoding class {0}:{1}", Schema.PackageName, Schema.ClassName)) ;
					
			enc.WriteUint8(20) ;
			Schema.Key.encode(enc) ;
			
			foreach (SchemaProperty prop in Schema.GetAllProperties()) {
				if (prop.Optional) {
					if (bit == 0) {
						bit =1 ;
					}
					if ((Properties.ContainsKey(prop.Name)) && (Properties[prop.Name] != null)) {
						mask |= bit ;
						propsToEncode.Add(prop) ;
					} else {
					}
					bit = bit << 1 ;
					if (bit == 256) {
						bit = 0 ;
						enc.WriteUint8((short)mask) ;
						mask = 0 ;
					}
				} else {
					propsToEncode.Add(prop) ;
				}
			}
			if (bit != 0) {
				enc.WriteUint8((short)mask) ;
			}		
			
			foreach (SchemaProperty prop in propsToEncode) {
				object obj = Properties[prop.Name] ;
				//log.Debug(String.Format("Encoding property {0}", prop.Name)) ;
				Session.EncodeValue(enc, prop.Type, obj) ;
			}
			foreach (SchemaStatistic stat in Schema.Statistics) {
				object obj = Statistics[stat.Name] ;
				Session.EncodeValue(enc, stat.Type, obj) ;
			}			
			log.Debug("Done") ;
		 
		 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:45,代码来源:QMFObject.cs


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