public ICirClass processTypeDefinition(ICirData cirData, TypeDefinition typeDefinition)
        {
            try
            {
                var classSignature = CirFactoryUtils.getTypeUniqueSignatureFromTypeReference(typeDefinition);
                var cirClass = getCirClass(cirData, classSignature);
                
                // map attributes for this classs
                if (typeDefinition.CustomAttributes != null && typeDefinition.CustomAttributes.Count > 0)
                {
                    foreach (CustomAttribute customAttribute in typeDefinition.CustomAttributes)
                    {
                        var constructorSignature = CirFactoryUtils.getFunctionUniqueSignatureFromMethodReference(customAttribute.Constructor);                        
                        var cirAttribute = new CirAttribute(constructorSignature);
                        foreach (var constructorParameter in customAttribute.ConstructorParameters)
                        {
//                            var type = constructorParameter.GetType().FullName;
                            cirAttribute.Parameters.Add(constructorParameter.ToString(), constructorParameter.GetType().FullName);
                        }
                        if (customAttribute.Fields.Count > 0 || customAttribute.Properties.Count > 0)
                        { 
                        }
                        cirClass.ClassAttributes.Add(cirAttribute);
                    }
                }

                
                if (false == cirClass.HasBeenProcessedByCirFactory)
                {
                    cirClass.HasBeenProcessedByCirFactory = true;
                    cirClass.Name = typeDefinition.Name;
                    cirClass.FullName = typeDefinition.FullName;
                    cirClass.Module = typeDefinition.Module.Name;
                    cirClass.Namespace = cirClass.Namespace;
                    cirClass.SymbolDef = Guid.NewGuid().ToString();
                    cirClass.IsAbstract = typeDefinition.IsAbstract;
                    //                cirClass.IsAnonymous = typeDefinition.
                    cirClass.IsClass = typeDefinition.IsClass;
                    cirClass.IsEnum = typeDefinition.IsEnum;
                    cirClass.IsInterface = typeDefinition.IsInterface;
                    cirClass.IsImport = typeDefinition.IsImport;
                    cirClass.IsNotPublic = typeDefinition.IsNotPublic;
                    cirClass.IsPublic = typeDefinition.IsPublic;
                    cirClass.HasSecurity = typeDefinition.HasSecurity;             
                }
                else
                    DI.log.info("This Class has already been processed, so only adding any possible extra methods: {0}", cirClass.Name);
                // handle constuctors

                foreach (MethodDefinition methodDefinition in typeDefinition.Constructors)
                {
                    ICirFunction cirFunction = processMethodDefinition(cirData, methodDefinition, null);
                    if (false == cirClass.dFunctions.ContainsValue(cirFunction))
                        cirClass.dFunctions.Add(cirFunction.FunctionSignature, cirFunction);

                    // try to find source code reference
                    if (cirFunction.FunctionsCalled.Count > 0 && cirClass.FileLine == null)
                        if (false == string.IsNullOrEmpty(cirFunction.FunctionsCalled[0].fileName))
                        {
                            cirClass.File = cirFunction.FunctionsCalled[0].fileName;
                            cirClass.FileLine = "0";    // set it to zero and try to map it later
                        }
                }
                // handle methods
                foreach (MethodDefinition methodDefinition in typeDefinition.Methods)
                {
                    ICirFunction cirFunction = processMethodDefinition(cirData, methodDefinition, null);
                    if (false == cirClass.dFunctions.ContainsValue(cirFunction))
                        cirClass.dFunctions.Add(cirFunction.FunctionSignature, cirFunction);

                }                
                return cirClass;
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in CirFactory.processTypeDefinition", true);
                return null;
            }
        }
        public ICirFunction processMethodDefinition(ICirData cirData, MethodDefinition methodDefinition, SequencePoint sequencePoint)
        {
            try
            {
                //var functionSignature = methodDefinition.ToString();
                var functionSignature = CirFactoryUtils.getFunctionUniqueSignatureFromMethodReference(methodDefinition);
                var functionClass = CirFactoryUtils.getTypeUniqueSignatureFromTypeReference(methodDefinition.DeclaringType);
                var cirFunction = getCirFunction(cirData, functionSignature, functionClass);
                if (false == cirFunction.HasBeenProcessedByCirFactory)
                {
                    if (methodDefinition.CustomAttributes != null && methodDefinition.CustomAttributes.Count > 0)
                    {
                        foreach (CustomAttribute customAttribute in methodDefinition.CustomAttributes)
                        {
                            var constructorSignature = CirFactoryUtils.getFunctionUniqueSignatureFromMethodReference(customAttribute.Constructor);
                            var cirAttribute = new CirAttribute(constructorSignature);
                            foreach (var constructorParameter in customAttribute.ConstructorParameters)
                            {
                                var type = constructorParameter.GetType().FullName;
                            }
                            if (customAttribute.Fields.Count > 0 || customAttribute.Properties.Count > 0)
                            {
                            }
                           // PublicDI.log.debug("Added attribute {0} to {1}", customAttribute.Constructor.Name, cirFunction.FunctionName);
                            cirFunction.FunctionAttributes.Add(cirAttribute);
                        }
                    }
                    

                    // map the common values with MethodReference
                    processMethodReference(cirData, methodDefinition, sequencePoint);

                    cirFunction.HasBeenProcessedByCirFactory = true;  // we need to put this in here or we will have an infinite loop on recursive functions
                    cirFunction.HasControlFlowGraph = true;           // ControlFlowGraph is use by the Viewers to determine if we have more than just a reference to this method
                    cirFunction.ParentClass.bClassHasMethodsWithControlFlowGraphs = true;  // also mark the parent class

                    cirFunction.IsStatic = methodDefinition.IsStatic;
                    cirFunction.IsUnmanaged = methodDefinition.IsUnmanaged;
                    cirFunction.IsUnmanagedExport = methodDefinition.IsUnmanagedExport;
                    cirFunction.IsVirtual = methodDefinition.IsVirtual;
                    cirFunction.IsSetter = methodDefinition.IsSetter;
                    cirFunction.IsGetter = methodDefinition.IsGetter;
                    cirFunction.IsRuntime = methodDefinition.IsRuntime;
                    cirFunction.IsPublic = methodDefinition.IsPublic;
                    cirFunction.IsPrivate = methodDefinition.IsPrivate;
                    cirFunction.IsPInvokeImpl = methodDefinition.IsPInvokeImpl;
                    cirFunction.IsNative = methodDefinition.IsNative;
                    cirFunction.IsManaged = methodDefinition.IsManaged;
                    cirFunction.IsInternalCall = methodDefinition.IsInternalCall;
                    cirFunction.IsIL = methodDefinition.IsIL;
                    cirFunction.IsConstructor = methodDefinition.IsConstructor;
                    cirFunction.IsAbstract = methodDefinition.IsAbstract;
                    cirFunction.HasSecurity = methodDefinition.HasSecurity;
                    cirFunction.HasBody = methodDefinition.HasBody;

                    // try to find the location of the current method by going for the first line of the first method
                    if (methodDefinition.HasBody)
                        foreach (Instruction instruction in methodDefinition.Body.Instructions)
                            if (instruction.SequencePoint != null )
                            {
                                cirFunction.File = instruction.SequencePoint.Document.Url;
                                if (instruction.SequencePoint.StartLine == 16707566) // means there is no source code ref                                
                                    cirFunction.FileLine = "0";
                                else
                                    cirFunction.FileLine = instruction.SequencePoint.StartLine.ToString();
                                break;
                            }
                    
                    // map method parameters (this could be on the MethodReference but if so we would have to check for doing it more than once:
                    foreach (ParameterDefinition parameter in methodDefinition.Parameters)
                    {
                        ICirFunctionParameter functionParameter = new CirFunctionParameter
                        {
                            ParameterName = parameter.ToString(),
                            ParameterType = parameter.ParameterType.FullName,
                            Constant = (parameter.Constant != null) ? parameter.Constant.ToString() : "",
                            HasConstant = parameter.HasConstant,
                            HasDefault = parameter.HasDefault,
                            Method = parameter.Method.ToString()
                        };

                        cirFunction.FunctionParameters.Add(functionParameter);
                    }

                    // map the calls made and the IsCalledBy                   
                    foreach (var methodCalled in CecilUtils.getMethodsCalledInsideMethod(methodDefinition))
                    {
                        ICirFunction cirCalledFunction = processMemberReference(cirData, methodCalled.memberReference, methodCalled.sequencePoint);

                        if (cirCalledFunction != null)
                        {
                            // store the fucntion called sequence
                            cirFunction.FunctionsCalled.Add(new CirFunctionCall(cirCalledFunction,methodCalled.sequencePoint)); 
                            // store the unique list of funcions called
                            if (false == cirFunction.FunctionsCalledUniqueList.Contains(cirCalledFunction))
                                cirFunction.FunctionsCalledUniqueList.Add(cirCalledFunction);

                            // map the FunctionCalled and FunctionIsCalledBy

                            var cirFunctionCall = new CirFunctionCall(cirCalledFunction, sequencePoint);
                            //cirFunction.FunctionsCalled.Add(cirFunctionCall);                            
                            cirCalledFunction.FunctionIsCalledBy.Add(cirFunctionCall);

                            
                            //if (false == cirCalledFunction.FunctionIsCalledBy.Contains(cirFunction))
                            //    cirCalledFunction.FunctionIsCalledBy.Add(cirFunction);
                        }
                    }                                       
                }
                // to implement if needed
              /*  foreach (var methodOverride in methodDefinition.Overrides)
                {
                    var name = methodOverride.GetType();
                }*/

                return cirFunction;
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in CirFactory.processMethodDefinition", true);
                return null;
            }            
        }