示例#1
0
        public CLogEncodingCLogTypeSearch FindTypeAndAdvance(string encoded, CLogLineMatch traceLineMatch, ref int index)
        {
            int tempIndex = index;
            CLogEncodingCLogTypeSearch ret = null;

            if (null != (ret = TypeEncoders.FindTypeAndAdvance(encoded, traceLineMatch, ref tempIndex)))
            {
                InUseTypeEncoders.AddType(ret);
                index = tempIndex;
                return(ret);
            }

            foreach (var config in ChainedConfigurations)
            {
                tempIndex = index;
                if (null != (ret = config.TypeEncoders.FindTypeAndAdvance(encoded, traceLineMatch, ref tempIndex)))
                {
                    InUseTypeEncoders.AddType(ret);
                    index = tempIndex;
                    return(ret);
                }
            }

            throw new CLogTypeNotFoundException("InvalidType:" + encoded, encoded, traceLineMatch);
        }
示例#2
0
        public void Lint()
        {
            this.MarkPhase = false;

            TypeEncoders.Lint();

            foreach (var child in this.ChainedConfigurations)
            {
                child.Lint();
            }

            RefreshTypeEncodersMarkBit(this, false);
        }
示例#3
0
文件: Serializer.cs 项目: McRain/ulib
        /// <summary>
        ///
        /// </summary>
        /// <param name="plugin"></param>
        /// <returns></returns>
        internal static bool PluginHandler(IUlibPlugin plugin)
        {
            var iPlugin = (ISerializePlugin)plugin;
            var tp      = iPlugin.GetType();
            var ioface  = tp.GetInterface("IObjectSerializer");

            if (ioface != null)
            {
                var externalPlugin = (IObjectSerializer)iPlugin;

                var encodeInfo     = tp.GetMethod("ObjectEncode");
                var encodeDelegate =
                    (ObjectEncoder)
                    Delegate.CreateDelegate(typeof(ObjectEncoder), iPlugin, encodeInfo);

                TypeEncoders.Add(externalPlugin.ObjectType, encodeDelegate);

                var decodeInfo     = tp.GetMethod("ObjectDecode");
                var decodeDelegate =
                    (ObjectDecoder)
                    Delegate.CreateDelegate(typeof(ObjectDecoder), iPlugin, decodeInfo);

                TypeDecoders.Add(externalPlugin.ObjectCode, decodeDelegate);
            }
            var icface = tp.GetInterface("IComponentSerializer");

            if (icface != null)
            {
                var externalPlugin = (IComponentSerializer)iPlugin;


                var encodeInfo     = tp.GetMethod("ComponentEncode");
                var encodeDelegate =
                    (ComponentEncoder)
                    Delegate.CreateDelegate(typeof(ComponentEncoder), iPlugin, encodeInfo);

                ComponentEncoders.Add(externalPlugin.ClassName, encodeDelegate);

                var decodeInfo     = tp.GetMethod("ComponentDecode");
                var decodeDelegate =
                    (ComponentDecoder)
                    Delegate.CreateDelegate(typeof(ComponentDecoder), iPlugin, decodeInfo);

                ComponentDecoders.Add(externalPlugin.ClassName, decodeDelegate);
            }
            return(true);
        }
示例#4
0
        public CLogEncodingCLogTypeSearch FindTypeAndAdvance(string encoded, CLogLineMatch traceLineMatch, ref int index)
        {
            int tempIndex = index;
            CLogEncodingCLogTypeSearch ret = null;

            //
            // First scan the type encoders in our main config file
            //
            if (null != (ret = TypeEncoders.FindTypeAndAdvance(encoded, traceLineMatch, ref tempIndex)))
            {
                InUseTypeEncoders.AddType(ret);
                index = tempIndex;
                return(ret);
            }

            //
            //  If we're unable to locate the type, iterate across each of our chained configs - note this is
            //     recursive;  such allowing for heirarchies
            //
            foreach (var config in ChainedConfigurations)
            {
                tempIndex = index;
                if (null != (ret = config.FindTypeAndAdvance(encoded, traceLineMatch, ref tempIndex)))
                {
                    InUseTypeEncoders.AddType(ret);
                    index = tempIndex;
                    return(ret);
                }
            }

            //
            // Attempt to get something for the user about the actual arg;  note this may be error prone as we are now confused
            //   by their inputs
            //
            string surroundingArray = encoded.Substring(index, 15);
            int    end = surroundingArray.IndexOf("}");

            if (-1 != end)
            {
                surroundingArray = surroundingArray.Substring(0, end);
            }

            throw new CLogTypeNotFoundException(encoded, "InvalidType:" + surroundingArray, traceLineMatch);
        }
示例#5
0
        public bool DecodeUsingCustomDecoder(CLogEncodingCLogTypeSearch node, IClogEventArg value, CLogLineMatch traceLine, out string decodedValue)
        {
            if (!TypeEncoders.DecodeUsingCustomDecoder(node, value, traceLine, out decodedValue))
            {
                return(false);
            }


            foreach (var config in ChainedConfigurations)
            {
                if (!config.DecodeUsingCustomDecoder(node, value, traceLine, out decodedValue))
                {
                    return(false);
                }
            }

            decodedValue = "ERROR:CustomDecoderNotFound:" + node.CustomDecoder + ":" + node.DefinationEncoding;
            return(false);
        }
示例#6
0
文件: Serializer.cs 项目: McRain/ulib
        /// <summary>
        ///
        /// </summary>
        /// <param name="plugin"></param>
        /// <returns></returns>
        internal static bool PluginRemove(IUlibPlugin plugin)
        {
            var tp     = plugin.GetType();
            var ioface = tp.GetInterface("IObjectSerializer");

            if (ioface != null)
            {
                var externalPlugin = (IObjectSerializer)plugin;

                if (TypeEncoders.ContainsKey(externalPlugin.ObjectType))
                {
                    lock (TypeEncoders)
                        TypeEncoders.Remove(externalPlugin.ObjectType);
                }

                if (TypeDecoders.ContainsKey(externalPlugin.ObjectCode))
                {
                    lock (TypeDecoders)
                        TypeDecoders.Remove(externalPlugin.ObjectCode);
                }
            }
            var icface = tp.GetInterface("IComponentSerializer");

            if (icface != null)
            {
                var externalPlugin = (IComponentSerializer)plugin;

                if (ComponentEncoders.ContainsKey(externalPlugin.ClassName))
                {
                    lock (ComponentEncoders)
                        ComponentEncoders.Remove(externalPlugin.ClassName);
                }

                if (ComponentDecoders.ContainsKey(externalPlugin.ClassName))
                {
                    lock (ComponentDecoders)
                        ComponentDecoders.Remove(externalPlugin.ClassName);
                }
            }
            return(true);
        }