Example #1
0
 string MatchAndGetKey(string Name, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     foreach (string Key in ParameterStore.Keys)
     {
         if (Key.Equals(Name))
         {
             return(Key);
         }
     }
     foreach (string Key in ParameterStore.Keys)
     {
         if (DecodeMethod(Key).Equals(DecodeMethod(Name)))
         {
             return(Key);
         }
     }
     foreach (string Key in ParameterStore.Keys)
     {
         if (Key.Equals(DecodeMethod(Name)))
         {
             return(Key);
         }
     }
     foreach (string Key in ParameterStore.Keys)
     {
         if (DecodeMethod(Key).Equals(Name))
         {
             return(Key);
         }
     }
     return(null);
 }
Example #2
0
 public ManualCodec(IEmittingCodec emittingCodec) : base(typeof(T), emittingCodec)
 {
     calculateSizeDelegate = (CalculateSizeDelegate)CalculateSizeMethod.CreateDelegate(typeof(CalculateSizeDelegate));
     encodeDelegate        = (EncodeDelegate)EncodeMethod.CreateDelegate(typeof(EncodeDelegate));
     decodeDelegate        = (DecodeDelegate)DecodeMethod.CreateDelegate(typeof(DecodeDelegate));
     decodeFastDelegate    = (DecodeDelegate)DecodeFastMethod.CreateDelegate(typeof(DecodeDelegate));
 }
Example #3
0
 public void DecodeTagsFor(DecodeDelegate decodeDelegate)
 {
     foreach (var tag in this)
     {
         decodeDelegate(tag, GetData());
     }
 }
Example #4
0
 public ManualCodec(ICodecContainer codecContainer, IEmittingCodec emittingCodec) : base(typeof(T), emittingCodec)
 {
     this.codecContainer   = codecContainer;
     calculateSizeDelegate = (CalculateSizeDelegate)CalculateSizeMethod.CreateDelegate(typeof(CalculateSizeDelegate));
     encodeDelegate        = (EncodeDelegate)EncodeMethod.CreateDelegate(typeof(EncodeDelegate));
     decodeDelegate        = (DecodeDelegate)DecodeMethod.CreateDelegate(typeof(DecodeDelegate));
     decodeFastDelegate    = (DecodeDelegate)DecodeFastMethod.CreateDelegate(typeof(DecodeDelegate));
 }
Example #5
0
        /**
         * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
         * <param name="img">Raw CAPTCHA image.</param>
         * <param name="timeout">Solving timeout (in seconds).</param>
         */
        public void Decode(DecodeDelegate callback, byte[] img, int timeout)
        {
            PollPayload payload = new PollPayload();

            payload.Callback = callback;
            payload.Captcha  = this.Upload(img);
            payload.Timeout  = timeout;
            new Thread(PollWithCallback).Start(payload);
        }
Example #6
0
 /**
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="img">Raw CAPTCHA image.</param>
  * <param name="timeout">Solving timeout (in seconds).</param>
  */
 public void Decode(DecodeDelegate callback, byte[] img, int timeout)
 {
     new Thread(DecodeWithCallback).Start(new DecodePayload()
     {
         Callback = callback,
         Image    = img,
         Timeout  = timeout,
     });
 }
Example #7
0
        /**
         * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
         * <param name="img">Raw CAPTCHA image.</param>
         * <param name="timeout">Solving timeout (in seconds).</param>
         * <param name="ext_data">Extra data used by special captchas types.</param>
         */
        public void Decode(DecodeDelegate callback, int timeout, Hashtable ext_data = null)
        {
            PollPayload payload = new PollPayload();

            payload.Callback = callback;
            payload.Captcha  = this.Upload(ext_data);
            payload.Timeout  = timeout;
            new Thread(PollWithCallback).Start(payload);
        }
        public static List <T> Decode <T>(FrameIterator iterator, DecodeDelegate <T> decodeFunction)
        {
            var result = new List <T>();

            //begin frame, list
            iterator.Next();
            while (!IsNextFrameIsDataStructureEndFrame(iterator))
            {
                result.Add(decodeFunction(iterator));
            }

            //end frame, list
            iterator.Next();
            return(result);
        }
        public static List <T> DecodeContainsNullable <T>(FrameIterator iterator, DecodeDelegate <T> decodeFunction) where T : class
        {
            var result = new List <T>();

            //begin frame, list
            iterator.Next();
            while (!IsNextFrameIsDataStructureEndFrame(iterator))
            {
                result.Add(IsNextFrameIsNullEndFrame(iterator) ? null : decodeFunction(iterator));
            }

            //end frame, list
            iterator.Next();
            return(result);
        }
Example #10
0
        public static List <T> Decode <T>(IEnumerator <Frame> iterator, DecodeDelegate <T> decodeFunction)
        {
            var result = new List <T>();

            //begin frame, list
            iterator.Take();
            while (!iterator.AtStructEnd())
            {
                result.Add(decodeFunction(iterator));
            }

            //end frame, list
            iterator.Take();
            return(result);
        }
Example #11
0
        /// <summary>
        /// Decode image from Photoshop's channel-separated formats to BGRA.
        /// </summary>
        public static unsafe void DecodeImage(BitmapLayer pdnLayer,
                                              PhotoshopFile.Layer psdLayer)
        {
            var            decodeContext = new DecodeContext(psdLayer, pdnLayer.Bounds);
            DecodeDelegate decoder       = null;

            if (decodeContext.ByteDepth == 4)
            {
                decoder = GetDecodeDelegate32(decodeContext.ColorMode);
            }
            else
            {
                decoder = GetDecodeDelegate(decodeContext.ColorMode);
            }

            DecodeImage(pdnLayer, decodeContext, decoder);
        }
        // public static void EncodeNullable<TKey, TValue>(ClientMessage clientMessage, IEnumerable<KeyValuePair<TKey, TValue>> collection,
        //         Action<ClientMessage, TKey> encodeKeyFunc,
        //         Action<ClientMessage, TValue> encodeValueFunc)
        // {
        //     if (collection == null)
        //     {
        //         clientMessage.Add(NullFrame.Copy());
        //     }
        //     else
        //     {
        //         Encode(clientMessage, collection, encodeKeyFunc, encodeValueFunc);
        //     }
        // }

        public static IList <KeyValuePair <TKey, TValue> > Decode <TKey, TValue>(FrameIterator iterator,
                                                                                 DecodeDelegate <TKey> decodeKeyFunc,
                                                                                 DecodeDelegate <TValue> decodeValueFunc)
        {
            var result = new List <KeyValuePair <TKey, TValue> >();

            //begin frame, map
            iterator.Next();
            while (!IsNextFrameIsDataStructureEndFrame(iterator))
            {
                var key   = decodeKeyFunc(iterator);
                var value = decodeValueFunc(iterator);
                result.Add(new KeyValuePair <TKey, TValue>(key, value));
            }
            //end frame, map
            iterator.Next();
            return(result);
        }
Example #13
0
        // public static void EncodeNullable<TKey, TValue>(ClientMessage clientMessage, IEnumerable<KeyValuePair<TKey, TValue>> collection,
        //         Action<ClientMessage, TKey> encodeKeyFunc,
        //         Action<ClientMessage, TValue> encodeValueFunc)
        // {
        //     if (collection == null)
        //     {
        //         clientMessage.Add(NullFrame.Copy());
        //     }
        //     else
        //     {
        //         Encode(clientMessage, collection, encodeKeyFunc, encodeValueFunc);
        //     }
        // }

        public static IList <KeyValuePair <TKey, TValue> > Decode <TKey, TValue>(IEnumerator <Frame> iterator,
                                                                                 DecodeDelegate <TKey> decodeKeyFunc,
                                                                                 DecodeDelegate <TValue> decodeValueFunc)
        {
            var result = new List <KeyValuePair <TKey, TValue> >();

            //begin frame, map
            iterator.Take();
            while (!iterator.AtStructEnd())
            {
                var key   = decodeKeyFunc(iterator);
                var value = decodeValueFunc(iterator);
                result.Add(new KeyValuePair <TKey, TValue>(key, value));
            }
            //end frame, map
            iterator.Take();
            return(result);
        }
        /// <summary>
        /// Decode image from Photoshop's channel-separated formats to BGRA.
        /// </summary>
        public static void DecodeImage(BitmapLayer pdnLayer,
                                       PhotoshopFile.Layer psdLayer)
        {
            UnityEngine.Profiling.Profiler.BeginSample("DecodeImage");
            var            decodeContext = new DecodeContext(psdLayer, pdnLayer.Bounds);
            DecodeDelegate decoder       = null;

            if (decodeContext.ByteDepth == 4)
            {
                decoder = GetDecodeDelegate32(decodeContext.ColorMode);
            }
            else
            {
                decoder = GetDecodeDelegate(decodeContext.ColorMode);
            }

            DecodeImage(pdnLayer, decodeContext, decoder);
            UnityEngine.Profiling.Profiler.EndSample();
        }
Example #15
0
        /// <summary>
        /// Decode image from Photoshop's channel-separated formats to BGRA,
        /// using the specified decode delegate on each row.
        /// </summary>
        private static unsafe void DecodeImage(BitmapLayer pdnLayer,
                                               DecodeContext decodeContext, DecodeDelegate decoder)
        {
            var psdLayer = decodeContext.Layer;
            var surface  = pdnLayer.Surface;
            var rect     = decodeContext.Rectangle;

            // Convert rows from the Photoshop representation, writing the
            // resulting ARGB values to to the Paint.NET Surface.

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                // Calculate index into ImageData source from row and column.
                int idxSrcPixel = (y - psdLayer.Rect.Top) * psdLayer.Rect.Width
                                  + (rect.Left - psdLayer.Rect.Left);
                int idxSrcByte = idxSrcPixel * decodeContext.ByteDepth;

                // Calculate pointers to destination Surface.
                var pDestRow   = surface.GetRowAddress(y);
                var pDestStart = pDestRow + decodeContext.Rectangle.Left;
                var pDestEnd   = pDestRow + decodeContext.Rectangle.Right;

                // For 16-bit images, take the higher-order byte from the image
                // data, which is now in little-endian order.
                if (decodeContext.ByteDepth == 2)
                {
                    idxSrcByte++;
                }

                // Decode the color and alpha channels
                decoder(pDestStart, pDestEnd, idxSrcByte, decodeContext);
                SetPDNAlphaRow(pDestStart, pDestEnd, idxSrcByte,
                               decodeContext.ByteDepth, decodeContext.AlphaChannel);

                // Apply layer masks(s) to the alpha channel
                var layerMaskAlphaRow = GetMaskAlphaRow(y,
                                                        decodeContext, decodeContext.LayerMaskContext);
                var userMaskAlphaRow = GetMaskAlphaRow(y,
                                                       decodeContext, decodeContext.UserMaskContext);
                ApplyPDNMask(pDestStart, pDestEnd, layerMaskAlphaRow, userMaskAlphaRow);
            }
        }
Example #16
0
        protected override void OnLoad()
        {
            _load              = GetMethod <LoadDelegate>("hcp_Load", true);
            _unload            = GetMethod <UnloadDelegate>("hcp_Unload", false);
            _toValue           = GetMethod <ToValueDelegate>("hcp_tovalue", false);
            _getArgumentHandle = GetMethod <GetArgumentHandleDelegate>("hcp_argat", false);
            _getMessage        = GetMethod <GetMessageDelegate>("hcp_GetMessage", false);
            _encode            = GetMethod <EncodeDelegate>("hcp_Encode", false);
            _decode            = GetMethod <DecodeDelegate>("hcp_Decode", false);
            _newCodec          = GetMethod <NewCodecDelegate>("hcp_NewCodec", false);
            _closeCodec        = GetMethod <CloseCodecDelegate>("hcp_CloseCodec", false);
            _loadCodec         = GetMethod <LoadCodecDelegate>("hcp_LoadCodec", false);
            _loadModel         = GetMethod <LoadModelDelegate>("hcp_LoadModel", false);

            try {
                _state = _load();
            } catch (Exception x) {
                throw new Exception("Error occured while calling 'hcp_Load': " + x.Message);
            }
        }
Example #17
0
        public void GetDelegates()
        {
            DspToolInfo dll = DllInfo[DllType];

            IntPtr pDecode            = Native.GetProcAddress(_pDll, "decode");
            IntPtr pEncode            = Native.GetProcAddress(_pDll, "encode");
            IntPtr pDspCorrelateCoefs = _pDll + dll.CorrelateCoefsAddress;
            IntPtr pDspEncodeFrame    = _pDll + dll.EncodeFrameAddress;

            if (DllType == DspToolType.OpenSource)
            {
                pDspCorrelateCoefs = Native.GetProcAddress(_pDll, "correlateCoefs");
                pDspEncodeFrame    = Native.GetProcAddress(_pDll, "encodeFrame");
            }

            Decode = Marshal.GetDelegateForFunctionPointer <DecodeDelegate>(pDecode);
            Encode = Marshal.GetDelegateForFunctionPointer <EncodeDelegate>(pEncode);
            DspCorrelateCoefsDll = Marshal.GetDelegateForFunctionPointer <DspCorrelateCoefsDelegate>(pDspCorrelateCoefs);
            DspEncodeFrameDll    = Marshal.GetDelegateForFunctionPointer <DspEncodeFrameDelegate>(pDspEncodeFrame);
        }
        /// <summary>
        /// Decode image from Photoshop's channel-separated formats to BGRA.
        /// </summary>
        public static JobHandle DecodeImage(BitmapLayer pdnLayer, PhotoshopFile.Layer psdLayer, JobHandle inputDeps)
        {
            UnityEngine.Profiling.Profiler.BeginSample("DecodeImage");
            var            decodeContext = new DecodeContext(psdLayer, pdnLayer.Bounds);
            DecodeDelegate decoder       = null;
            DecodeType     decoderType   = 0;

            if (decodeContext.ByteDepth == 4)
            {
                decoder = GetDecodeDelegate32(decodeContext.ColorMode, ref decoderType);
            }
            else
            {
                decoder = GetDecodeDelegate(decodeContext.ColorMode, ref decoderType);
            }

            JobHandle jobHandle = DecodeImage(pdnLayer, decodeContext, decoderType, inputDeps);

            UnityEngine.Profiling.Profiler.EndSample();
            return(jobHandle);
        }
Example #19
0
        public void DecodeTagsFor(DecodeDelegate decodeDelegate, IKeepUnrecognizedCfg unrecognizedKeeper, string tag)
        {
            BaseClassChain.Add(tag);
            try {
                foreach (var t in this)
                {
                    var data = GetData();

                    if (decodeDelegate(t, data))
                    {
                        continue;
                    }

                    BaseClassChain.Add(t);
                    unrecognizedKeeper.UnrecognizedStd.Add(BaseClassChain, data);
                    BaseClassChain.RemoveLast();
                }
            }
            finally {
                BaseClassChain.RemoveLast();
            }
        }
Example #20
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="st">CAPTCHA image byte stream.</param>
  */
 public void Decode(DecodeDelegate callback, Stream st)
 {
     this.Decode(callback, this.Load(st), 0);
 }
Example #21
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="fn">CAPTCHA image file name.</param>
  * <param name="timeout">Solving timeout (in seconds).</param>
  */
 public void Decode(DecodeDelegate callback, string fn, int timeout)
 {
     this.Decode(callback, this.Load(fn), timeout);
 }
Example #22
0
 public void RawSet(string Name, string Value, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     if (Name.Trim().Length == 0) return;
     string SafeName = SafeRawMethod(Name);
     string SafeValue = SafeRawMethod(Value);
     string Key = MatchAndGetKey(SafeName, EncodeMethod, DecodeMethod);
     if(Key == null)
         ParameterStore[SafeName] = new List<string>() { SafeValue };
     else
         ParameterStore[Key] = new List<string>() { SafeValue };
 }
Example #23
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="st">CAPTCHA image byte stream.</param>
  * <param name="timeout">Solving timeout (in seconds).</param>
  */
 public void Decode(DecodeDelegate callback, Stream st, int timeout)
 {
     this.Decode(callback, this.Load(st), timeout);
 }
Example #24
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="st">CAPTCHA image byte stream.</param>
  */
 public void Decode(DecodeDelegate callback, Stream st)
 {
     this.Decode(callback, this.Load(st), 0);
 }
Example #25
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="fn">CAPTCHA image file name.</param>
  */
 public void Decode(DecodeDelegate callback, string fn)
 {
     this.Decode(callback, this.Load(fn), 0);
 }
Example #26
0
 public static IDictionary <TKey, TValue> DecodeNullable <TKey, TValue>(FrameIterator iterator, DecodeDelegate <TKey> decodeKey, DecodeDelegate <TValue> decodeValue)
 {
     return(IsNextFrameIsNullEndFrame(iterator) ? null : Decode(iterator, decodeKey, decodeValue));
 }
Example #27
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="img">Raw CAPTCHA image.</param>
  */
 public void Decode(DecodeDelegate callback, byte[] img)
 {
     this.Decode(callback, img, 0);
 }
Example #28
0
 public string RawGet(string Name, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     string SafeName = SafeRawMethod(Name);
     string Key = MatchAndGetKey(SafeName, EncodeMethod, DecodeMethod);
     if (Key == null)
     {
         throw new Exception("Parameter not found");
     }
     else
     {
         List<string> Values = ParameterStore[Key];
         return Values[0];
     }
 }
Example #29
0
 public static T DecodeNullable <T>(ClientMessage.FrameIterator iterator, DecodeDelegate <T> decode) where T : class
 {
     return(IsNextFrameIsNullEndFrame(iterator) ? null : decode(iterator));
 }
Example #30
0
 public List<string> RawGetAll(string Name, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     string SafeName = SafeRawMethod(Name);
     string Key = MatchAndGetKey(Name, EncodeMethod, DecodeMethod);
     if (Key == null)
     {
         throw new Exception("Parameter not found");
     }
     else
     {
         return new List<string>(ParameterStore[Key]);
     }
 }
Example #31
0
 public bool RawHas(string Name, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     string SafeName = SafeRawMethod(Name);
     string Key = MatchAndGetKey(SafeName, EncodeMethod, DecodeMethod);
     if (Key == null)
     {
         return false;
     }
     else
     {
         return true;
     }
 }
Example #32
0
 public void RawSet(string Name, int Position, string Value, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     if (Name.Trim().Length == 0) return;
     string SafeName = SafeRawMethod(Name);
     string SafeValue = SafeRawMethod(Value);
     if (Position < 0) return;
     string Key = MatchAndGetKey(SafeName, EncodeMethod, DecodeMethod);
     if (Key == null)
     {
         ParameterStore[SafeName] = new List<string>() { SafeValue };
     }
     else
     {
         if (Position >= ParameterStore[Key].Count)
         {
             this.Add(Key, SafeValue);
         }
         else
         {
             ParameterStore[Key][Position] = SafeValue;
         }
     }
 }
Example #33
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="fn">CAPTCHA image file name.</param>
  */
 public void Decode(DecodeDelegate callback, string fn)
 {
     this.Decode(callback, this.Load(fn), 0);
 }
Example #34
0
 /**
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="img">Raw CAPTCHA image.</param>
  * <param name="timeout">Solving timeout (in seconds).</param>
  */
 public void Decode(DecodeDelegate callback, byte[] img, int timeout)
 {
     PollPayload payload = new PollPayload();
     payload.Callback = callback;
     payload.Captcha = this.Upload(img);
     payload.Timeout = timeout;
     new Thread(PollWithCallback).Start(payload);
 }
Example #35
0
 /**
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="img">Raw CAPTCHA image.</param>
  * <param name="timeout">Solving timeout (in seconds).</param>
  */
 public void Decode(DecodeDelegate callback, byte[] img, int timeout)
 {
     new Thread(DecodeWithCallback).Start(new DecodePayload() {
         Callback = callback,
         Image = img,
         Timeout = timeout,
     });
 }
 public static IDictionary <TKey, TValue> DecodeNullable <TKey, TValue>(IEnumerator <Frame> iterator, DecodeDelegate <TKey> decodeKey, DecodeDelegate <TValue> decodeValue)
 {
     return(iterator.SkipNull() ? null : Decode(iterator, decodeKey, decodeValue));
 }
Example #37
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="st">CAPTCHA image byte stream.</param>
  * <param name="timeout">Solving timeout (in seconds).</param>
  */
 public void Decode(DecodeDelegate callback, Stream st, int timeout)
 {
     this.Decode(callback, this.Load(st), timeout);
 }
Example #38
0
 public void RawAdd(string Name, string Value, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     if (Name.Trim().Length == 0) return;
     string SafeName = SafeRawMethod(Name);
     string SafeValue = SafeRawMethod(Value);
     string Key = MatchAndGetKey(SafeName, EncodeMethod, DecodeMethod);
     if (Key == null)
     {
         List<string> Values = new List<string>();
         Values.Add(SafeValue);
         ParameterStore.Add(SafeName, Values);
     }
     else
     {
         ParameterStore[Key].Add(SafeValue);
     }
 }
Example #39
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="fn">CAPTCHA image file name.</param>
  * <param name="timeout">Solving timeout (in seconds).</param>
  */
 public void Decode(DecodeDelegate callback, string fn, int timeout)
 {
     this.Decode(callback, this.Load(fn), timeout);
 }
Example #40
0
 /**
  * <see cref="M:Client.Decode(DecodeDelegate, byte[], int)"/>
  * <param name="callback">A delegate to call when the CAPTCHA is solved or timed out.</param>
  * <param name="img">Raw CAPTCHA image.</param>
  */
 public void Decode(DecodeDelegate callback, byte[] img)
 {
     this.Decode(callback, img, 0);
 }
Example #41
0
        public static IDictionary <TKey, TValue> Decode <TKey, TValue>(FrameIterator iterator, DecodeDelegate <TKey> decodeKey, DecodeDelegate <TValue> decodeValue)
        {
            var result = new Dictionary <TKey, TValue>();

            //begin frame, map
            iterator.Next();

            while (!IsNextFrameIsDataStructureEndFrame(iterator))
            {
                var key   = decodeKey(iterator);
                var value = decodeValue(iterator);
                result[key] = value;
            }

            //end frame, map
            iterator.Next();
            return(result);
        }
Example #42
0
 public void RawRemove(string Name, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     string SafeName = SafeRawMethod(Name);
     string Key = MatchAndGetKey(SafeName, EncodeMethod, DecodeMethod);
     if (Key != null)
     {
         ParameterStore.Remove(Key);
     }
 }
Example #43
0
 public void RawSet(string Name, List<string> Values, SafeRawDelegate SafeRawMethod, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     if (Name.Trim().Length == 0) return;
     string SafeName = SafeRawMethod(Name);
     List<string> SafeValues = new List<string>();
     foreach (string Value in Values)
     {
         SafeValues.Add(SafeRawMethod(Value));
     }
     string Key = MatchAndGetKey(SafeName, EncodeMethod, DecodeMethod);
     if (Key == null)
     {
         ParameterStore.Add(SafeName, SafeValues);
     }
     else
     {
         ParameterStore[Key] = SafeValues;
     }
 }
        public static IDictionary <TKey, TValue> Decode <TKey, TValue>(IEnumerator <Frame> iterator, DecodeDelegate <TKey> decodeKey, DecodeDelegate <TValue> decodeValue)
        {
            var result = new Dictionary <TKey, TValue>();

            //begin frame, map
            iterator.Take();

            while (!iterator.AtStructEnd())
            {
                var key   = decodeKey(iterator);
                var value = decodeValue(iterator);
                result[key] = value;
            }

            //end frame, map
            iterator.Take();
            return(result);
        }
 public static T DecodeNullable <T>(IEnumerator <Frame> iterator, DecodeDelegate <T> decode) where T : class
 {
     return(iterator.SkipNull() ? null : decode(iterator));
 }
Example #46
0
 string MatchAndGetKey(string Name, EncodeDelegate EncodeMethod, DecodeDelegate DecodeMethod)
 {
     foreach(string Key in ParameterStore.Keys)
     {
         if(Key.Equals(Name)) return Key;
     }
     foreach(string Key in ParameterStore.Keys)
     {
         if(DecodeMethod(Key).Equals(DecodeMethod(Name))) return Key;
     }
     foreach(string Key in ParameterStore.Keys)
     {
         if(Key.Equals(DecodeMethod(Name))) return Key;
     }
     foreach(string Key in ParameterStore.Keys)
     {
         if(DecodeMethod(Key).Equals(Name)) return Key;
     }
     return null;
 }