// Private Methods static string DotNetNameToPhpName(string fullName) { if (fullName == null) { throw new ArgumentNullException("fullName"); } fullName = fullName.Replace("`", "__"); return(string.Join("", from i in fullName.Replace("+", ".").Split('.') select PhpQualifiedName.TokenNsSeparator + PhpQualifiedName.SanitizePhpName(i))); }
public void SetClassName(PhpQualifiedName className, MethodTranslationInfo translationInfo) { _className = className.MakeAbsolute(); _translationInfo = translationInfo; }
/// <summary> /// Tworzy instancję obiektu /// <param name="className"></param> /// </summary> public ClassCodeRequest(PhpQualifiedName className) { ClassName = className; }
/// <summary> /// Tworzy instancję obiektu /// <param name="name">Nazwa klasy</param> /// <param name="baseTypeName">Nazwa klasy</param> /// </summary> public PhpClassDefinition(PhpQualifiedName name, PhpQualifiedName baseTypeName) { _name = name; _baseTypeName = baseTypeName; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpClassDefinition() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Name## ##BaseTypeName## ##Methods## ##Fields## implement ToString Name=##Name##, BaseTypeName=##BaseTypeName##, Methods=##Methods##, Fields=##Fields## implement equals Name, BaseTypeName, Methods, Fields implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="name">Nazwa klasy</param> /// </summary> public PhpClassDefinition(PhpQualifiedName name) { _name = name; }
void Update() { if (_initialized) { return; } _initialized = true; var ati = _info.GetOrMakeTranslationInfo(_type.Assembly); var declaringTypeTranslationInfo = (object)_type.DeclaringType == null ? null : _info.GetOrMakeTranslationInfo(_type.DeclaringType); var ats = _type.GetCustomAttributes(false); _ignoreNamespace = ats.OfType <IgnoreNamespaceAttribute>().Any(); #region ScriptName { if (_ignoreNamespace) { _scriptName = (PhpQualifiedName)PhpQualifiedName.SanitizePhpName(_type.Name); // only short name without namespace } else if (_type.IsGenericType) { _scriptName = (PhpQualifiedName)DotNetNameToPhpName(_type.FullName ?? _type.Name); // beware of generic types } else { _scriptName = (PhpQualifiedName)DotNetNameToPhpName(_type.FullName ?? _type.Name); } var scriptNameAttribute = ats.OfType <ScriptNameAttribute>().FirstOrDefault(); if (scriptNameAttribute != null) { if (scriptNameAttribute.Name.StartsWith(PhpQualifiedName.TokenNsSeparator.ToString(CultureInfo.InvariantCulture))) { _scriptName = (PhpQualifiedName)scriptNameAttribute.Name; } else if (IgnoreNamespace) { _scriptName = (PhpQualifiedName)(PhpQualifiedName.TokenNsSeparator + scriptNameAttribute.Name); } else { _scriptName = (PhpQualifiedName) (DotNetNameToPhpName(_type.FullName) + PhpQualifiedName.TokenNsSeparator + scriptNameAttribute.Name); } } if (declaringTypeTranslationInfo != null) { _scriptName = (PhpQualifiedName)(declaringTypeTranslationInfo.ScriptName + "__" + _type.Name); // parent clas followed by __ and short name } } #endregion #region Module name { //if (declaringTypeTranslationInfo != null && declaringTypeTranslationInfo.ModuleName != null) _moduleName = new PhpCodeModuleName(_type, ati, declaringTypeTranslationInfo); } #endregion #region PageAttribute { var pageAttribute = ats.OfType <PageAttribute>().FirstOrDefault(); _isPage = pageAttribute != null; _pageMethod = _isPage ? FindPhpMainMethod(_type) : null; } #endregion #region AsArrayAttribute { var asArrayAttribute = ats.OfType <AsArrayAttribute>().FirstOrDefault(); _isArray = asArrayAttribute != null; } #endregion #region SkipAttribute { var skipAttribute = ats.OfType <SkipAttribute>().FirstOrDefault(); if (skipAttribute != null) { _skip = true; } } #endregion #region BuiltInAttribute { var builtInAttribute = ats.OfType <BuiltInAttribute>().FirstOrDefault(); if (builtInAttribute != null) { _buildIn = true; } } #endregion if (_skip && _buildIn) { throw new Exception("Don't mix SkipAttribute and BuiltInAttribute for type " + _type.ExcName()); } if (_buildIn) { _skip = true; } if (_type.IsGenericParameter) { _skip = true; } if (_isArray) { _skip = true; } }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public ClassCodeRequest() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##ClassName## implement ToString ClassName=##ClassName## implement equals ClassName implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="className"></param> /// </summary> public ClassCodeRequest(PhpQualifiedName className) { ClassName = className; }
public void SetClassName(PhpQualifiedName phpClassName, ClassTranslationInfo classTi ) { _className = phpClassName; _classTi = classTi; }
public PhpClassDefinition FindOrCreateClass(PhpQualifiedName phpClassName, PhpQualifiedName baseClass) { var c = _classes.FirstOrDefault(i => phpClassName == i.Name); if (c != null) return c; c = new PhpClassDefinition(phpClassName, baseClass); _classes.Add(c); return c; }